From 8745cd1b8250c370b1681f0728116150c72a4279 Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Tue, 5 Mar 2019 16:31:48 +0100 Subject: setup react-intl translations managing script --- .babelrc | 9 +- package-lock.json | 38 ++ package.json | 3 + src/components/subscription/SubscriptionForm.js | 60 ++- src/containers/settings/EditUserScreen.js | 44 +- src/features/shareFranz/Component.js | 52 +- translations/manage-translations.js | 10 + .../messages/src/components/auth/Import.json | 54 ++ .../messages/src/components/auth/Invite.json | 93 ++++ .../messages/src/components/auth/Login.json | 119 +++++ .../messages/src/components/auth/Password.json | 93 ++++ .../messages/src/components/auth/Pricing.json | 54 ++ .../messages/src/components/auth/Signup.json | 158 ++++++ .../messages/src/components/auth/Welcome.json | 28 + .../messages/src/components/layout/AppLayout.json | 80 +++ .../messages/src/components/layout/Sidebar.json | 54 ++ .../content/ErrorHandlers/WebviewErrorHandler.json | 67 +++ .../services/content/ServiceDisabled.json | 28 + .../src/components/services/content/Services.json | 28 + .../services/content/WebviewCrashHandler.json | 54 ++ .../src/components/services/tabs/TabItem.json | 119 +++++ .../settings/account/AccountDashboard.json | 210 ++++++++ .../settings/navigation/SettingsNavigation.json | 80 +++ .../settings/recipes/RecipesDashboard.json | 106 ++++ .../settings/services/EditServiceForm.json | 288 +++++++++++ .../components/settings/services/ServiceError.json | 54 ++ .../components/settings/services/ServiceItem.json | 41 ++ .../settings/services/ServicesDashboard.json | 119 +++++ .../settings/settings/EditSettingsForm.json | 223 ++++++++ .../src/components/settings/user/EditUserForm.json | 80 +++ .../components/subscription/SubscriptionForm.json | 171 +++++++ .../components/subscription/SubscriptionPopup.json | 28 + .../ui/PremiumFeatureContainer/index.json | 15 + .../src/components/util/ErrorBoundary/index.json | 28 + .../src/containers/settings/EditServiceScreen.json | 197 ++++++++ .../containers/settings/EditSettingsScreen.json | 158 ++++++ .../src/containers/settings/EditUserScreen.json | 119 +++++ .../messages/src/features/delayApp/Component.json | 41 ++ .../src/features/shareFranz/Component.json | 93 ++++ .../messages/src/helpers/validation-helpers.json | 67 +++ translations/messages/src/i18n/globalMessages.json | 93 ++++ translations/messages/src/lib/Menu.json | 561 +++++++++++++++++++++ 42 files changed, 3933 insertions(+), 84 deletions(-) create mode 100644 translations/manage-translations.js create mode 100644 translations/messages/src/components/auth/Import.json create mode 100644 translations/messages/src/components/auth/Invite.json create mode 100644 translations/messages/src/components/auth/Login.json create mode 100644 translations/messages/src/components/auth/Password.json create mode 100644 translations/messages/src/components/auth/Pricing.json create mode 100644 translations/messages/src/components/auth/Signup.json create mode 100644 translations/messages/src/components/auth/Welcome.json create mode 100644 translations/messages/src/components/layout/AppLayout.json create mode 100644 translations/messages/src/components/layout/Sidebar.json create mode 100644 translations/messages/src/components/services/content/ErrorHandlers/WebviewErrorHandler.json create mode 100644 translations/messages/src/components/services/content/ServiceDisabled.json create mode 100644 translations/messages/src/components/services/content/Services.json create mode 100644 translations/messages/src/components/services/content/WebviewCrashHandler.json create mode 100644 translations/messages/src/components/services/tabs/TabItem.json create mode 100644 translations/messages/src/components/settings/account/AccountDashboard.json create mode 100644 translations/messages/src/components/settings/navigation/SettingsNavigation.json create mode 100644 translations/messages/src/components/settings/recipes/RecipesDashboard.json create mode 100644 translations/messages/src/components/settings/services/EditServiceForm.json create mode 100644 translations/messages/src/components/settings/services/ServiceError.json create mode 100644 translations/messages/src/components/settings/services/ServiceItem.json create mode 100644 translations/messages/src/components/settings/services/ServicesDashboard.json create mode 100644 translations/messages/src/components/settings/settings/EditSettingsForm.json create mode 100644 translations/messages/src/components/settings/user/EditUserForm.json create mode 100644 translations/messages/src/components/subscription/SubscriptionForm.json create mode 100644 translations/messages/src/components/subscription/SubscriptionPopup.json create mode 100644 translations/messages/src/components/ui/PremiumFeatureContainer/index.json create mode 100644 translations/messages/src/components/util/ErrorBoundary/index.json create mode 100644 translations/messages/src/containers/settings/EditServiceScreen.json create mode 100644 translations/messages/src/containers/settings/EditSettingsScreen.json create mode 100644 translations/messages/src/containers/settings/EditUserScreen.json create mode 100644 translations/messages/src/features/delayApp/Component.json create mode 100644 translations/messages/src/features/shareFranz/Component.json create mode 100644 translations/messages/src/helpers/validation-helpers.json create mode 100644 translations/messages/src/i18n/globalMessages.json create mode 100644 translations/messages/src/lib/Menu.json diff --git a/.babelrc b/.babelrc index 299d5b4a0..dd23bdabf 100644 --- a/.babelrc +++ b/.babelrc @@ -25,7 +25,12 @@ } ], "@babel/proposal-throw-expressions", - "@babel/syntax-dynamic-import" + "@babel/syntax-dynamic-import", + ["react-intl", { + "messagesDir": "./translations/messages/", + "enforceDescriptions": false, + "extractSourceLocation": true + }] ], "sourceMaps": "inline" -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 1a66f4ffd..82e9c9997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3157,6 +3157,17 @@ } } }, + "babel-plugin-react-intl": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-react-intl/-/babel-plugin-react-intl-3.0.1.tgz", + "integrity": "sha512-FqnEO+Tq7kJVUPKsSG3s5jaHi3pAC4RUR11IrscvjsfkOApLP2DtzNo6dtQ+tX+OzEzJx7cUms8aCw5BFyW5xg==", + "dev": true, + "requires": { + "@babel/runtime": "^7.0.0", + "intl-messageformat-parser": "^1.2.0", + "mkdirp": "^0.5.1" + } + }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -11228,6 +11239,15 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -11263,6 +11283,12 @@ "graceful-fs": "^4.1.6" } }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -14967,6 +14993,18 @@ } } }, + "react-intl-translations-manager": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/react-intl-translations-manager/-/react-intl-translations-manager-5.0.3.tgz", + "integrity": "sha512-EfBeugnOGFcdUbQyY9TqBMbuauQ8wm73ZqFr0UqCljhbXl7YDHQcVzclWFRkVmlUffzxitLQFhAZEVVeRNQSwA==", + "dev": true, + "requires": { + "chalk": "^2.3.2", + "glob": "^7.1.2", + "json-stable-stringify": "^1.0.1", + "mkdirp": "^0.5.1" + } + }, "react-is": { "version": "16.8.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.1.tgz", diff --git a/package.json b/package.json index c28d29e90..33a0fb0d9 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "start:live": "cross-env LIVE_API=1 npm start", "dev": "cross-env NODE_ENV=development gulp dev", "lint": "eslint src", + "manage-translations": "node ./translations/manage-translations.js", "sign": "gulp sign", "prebuild": "gulp build", "build": "npx electron-builder --publish onTag", @@ -108,6 +109,7 @@ "@types/uuid": "3.4.4", "babel-eslint": "10.0.1", "babel-loader": "^8.0.4", + "babel-plugin-react-intl": "3.0.1", "conventional-changelog-cli": "2.0.11", "cross-env": "^5.0.5", "cz-conventional-changelog": "2.1.0", @@ -137,6 +139,7 @@ "mocha": "5.2.0", "node-sass": "4.11.0", "prettier": "1.15.2", + "react-intl-translations-manager": "5.0.3", "terser-webpack-plugin": "1.2.1", "ts-loader": "5.3.2", "tslint": "5.12.0", diff --git a/src/components/subscription/SubscriptionForm.js b/src/components/subscription/SubscriptionForm.js index 90da8ddc3..7a818d100 100644 --- a/src/components/subscription/SubscriptionForm.js +++ b/src/components/subscription/SubscriptionForm.js @@ -35,31 +35,29 @@ const messages = defineMessages({ id: 'subscription.includedFeatures', defaultMessage: '!!!The Franz Premium Supporter Account includes', }, - features: { - onpremise: { - id: 'subscription.features.onpremise.mattermost', - defaultMessage: '!!!Add on-premise/hosted services like Mattermost', - }, - noInterruptions: { - id: 'subscription.features.noInterruptions', - defaultMessage: '!!!No app delays & nagging to upgrade license', - }, - proxy: { - id: 'subscription.features.proxy', - defaultMessage: '!!!Proxy support for services', - }, - spellchecker: { - id: 'subscription.features.spellchecker', - defaultMessage: '!!!Support for Spellchecker', - }, - ads: { - id: 'subscription.features.ads', - defaultMessage: '!!!No ads, ever!', - }, - comingSoon: { - id: 'subscription.features.comingSoon', - defaultMessage: '!!!coming soon', - }, + onpremise: { + id: 'subscription.features.onpremise.mattermost', + defaultMessage: '!!!Add on-premise/hosted services like Mattermost', + }, + noInterruptions: { + id: 'subscription.features.noInterruptions', + defaultMessage: '!!!No app delays & nagging to upgrade license', + }, + proxy: { + id: 'subscription.features.proxy', + defaultMessage: '!!!Proxy support for services', + }, + spellchecker: { + id: 'subscription.features.spellchecker', + defaultMessage: '!!!Support for Spellchecker', + }, + ads: { + id: 'subscription.features.ads', + defaultMessage: '!!!No ads, ever!', + }, + comingSoon: { + id: 'subscription.features.comingSoon', + defaultMessage: '!!!coming soon', }, euTaxInfo: { id: 'subscription.euTaxInfo', @@ -85,7 +83,7 @@ export default @observer class SubscriptionForm extends Component { showSkipOption: false, skipAction: () => null, skipButtonLabel: '', - } + }; static contextTypes = { intl: intlShape, @@ -162,18 +160,18 @@ export default @observer class SubscriptionForm extends Component {

diff --git a/src/containers/settings/EditUserScreen.js b/src/containers/settings/EditUserScreen.js index bade928a0..81f689400 100644 --- a/src/containers/settings/EditUserScreen.js +++ b/src/containers/settings/EditUserScreen.js @@ -23,23 +23,21 @@ const messages = defineMessages({ id: 'settings.user.form.email', defaultMessage: '!!!Email', }, - accountType: { - label: { - id: 'settings.user.form.accountType.label', - defaultMessage: '!!!Account type', - }, - individual: { - id: 'settings.user.form.accountType.individual', - defaultMessage: '!!!Individual', - }, - nonProfit: { - id: 'settings.user.form.accountType.non-profit', - defaultMessage: '!!!Non-Profit', - }, - company: { - id: 'settings.user.form.accountType.company', - defaultMessage: '!!!Company', - }, + accountTypeLabel: { + id: 'settings.user.form.accountType.label', + defaultMessage: '!!!Account type', + }, + accountTypeIndividual: { + id: 'settings.user.form.accountType.individual', + defaultMessage: '!!!Individual', + }, + accountTypeNonProfit: { + id: 'settings.user.form.accountType.non-profit', + defaultMessage: '!!!Non-Profit', + }, + accountTypeCompany: { + id: 'settings.user.form.accountType.company', + defaultMessage: '!!!Company', }, currentPassword: { id: 'settings.user.form.currentPassword', @@ -94,21 +92,21 @@ export default @inject('stores', 'actions') @observer class EditUserScreen exten accountType: { value: user.accountType, validators: [required], - label: intl.formatMessage(messages.accountType.label), + label: intl.formatMessage(messages.accountTypeLabel), options: [{ value: 'individual', - label: intl.formatMessage(messages.accountType.individual), + label: intl.formatMessage(messages.accountTypeIndividual), }, { value: 'non-profit', - label: intl.formatMessage(messages.accountType.nonProfit), + label: intl.formatMessage(messages.accountTypeNonProfit), }, { value: 'company', - label: intl.formatMessage(messages.accountType.company), + label: intl.formatMessage(messages.accountTypeCompany), }], }, organization: { - label: intl.formatMessage(messages.accountType.company), - placeholder: intl.formatMessage(messages.accountType.company), + label: intl.formatMessage(messages.accountTypeCompany), + placeholder: intl.formatMessage(messages.accountTypeCompany), value: user.organization, }, oldPassword: { diff --git a/src/features/shareFranz/Component.js b/src/features/shareFranz/Component.js index d463664df..ef43a54fa 100644 --- a/src/features/shareFranz/Component.js +++ b/src/features/shareFranz/Component.js @@ -20,29 +20,25 @@ const messages = defineMessages({ id: 'feature.shareFranz.text', defaultMessage: '!!!Tell your friends and colleagues how awesome Franz is and help us to spread the word.', }, - actions: { - email: { - id: 'feature.shareFranz.action.email', - defaultMessage: '!!!Share as email', - }, - facebook: { - id: 'feature.shareFranz.action.facebook', - defaultMessage: '!!!Share on Facebook', - }, - twitter: { - id: 'feature.shareFranz.action.twitter', - defaultMessage: '!!!Share on Twitter', - }, + actionsEmail: { + id: 'feature.shareFranz.action.email', + defaultMessage: '!!!Share as email', }, - shareText: { - email: { - id: 'feature.shareFranz.shareText.email', - defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com', - }, - twitter: { - id: 'feature.shareFranz.shareText.twitter', - defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com /cc @MeetFranz', - }, + actionsFacebook: { + id: 'feature.shareFranz.action.facebook', + defaultMessage: '!!!Share on Facebook', + }, + actionsTwitter: { + id: 'feature.shareFranz.action.twitter', + defaultMessage: '!!!Share on Twitter', + }, + shareTextEmail: { + id: 'feature.shareFranz.shareText.email', + defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com', + }, + shareTextTwitter: { + id: 'feature.shareFranz.shareText.twitter', + defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com /cc @MeetFranz', }, }); @@ -90,7 +86,7 @@ const styles = theme => ({ export default @injectSheet(styles) @inject('stores') @observer class ShareFranzModal extends Component { static propTypes = { classes: PropTypes.object.isRequired, - } + }; static contextTypes = { intl: intlShape, @@ -128,17 +124,17 @@ export default @injectSheet(styles) @inject('stores') @observer class ShareFranz

{intl.formatMessage(messages.text)}