From 1184bc9bf4d43a71088d0664dafdcfa8edb90ef4 Mon Sep 17 00:00:00 2001 From: Pierre Burgy Date: Mon, 14 Aug 2017 17:34:49 +0200 Subject: [PATCH] Remove i18n in plugin generators --- packages/strapi-admin/package.json | 2 +- .../internals/generators/component/index.js | 5 -- .../internals/generators/container/index.js | 5 -- .../lib/internals/generators/index.js | 2 - .../generators/language/add-locale-data.hbs | 1 - .../generators/language/app-locale.hbs | 2 - .../language/format-translation-messages.hbs | 1 - .../internals/generators/language/index.js | 80 ------------------- .../generators/language/intl-locale-data.hbs | 1 - .../language/polyfill-intl-locale.hbs | 1 - .../language/translation-messages.hbs | 1 - .../generators/language/translations-json.hbs | 1 - 12 files changed, 1 insertion(+), 101 deletions(-) delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/add-locale-data.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/app-locale.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/format-translation-messages.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/index.js delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/intl-locale-data.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/polyfill-intl-locale.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/translation-messages.hbs delete mode 100644 packages/strapi-helper-plugin/lib/internals/generators/language/translations-json.hbs diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 5e1308ab4c..e984fc80e0 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -44,4 +44,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-helper-plugin/lib/internals/generators/component/index.js b/packages/strapi-helper-plugin/lib/internals/generators/component/index.js index 132ca1d841..f1060e4bc3 100644 --- a/packages/strapi-helper-plugin/lib/internals/generators/component/index.js +++ b/packages/strapi-helper-plugin/lib/internals/generators/component/index.js @@ -29,11 +29,6 @@ module.exports = { name: 'wantCSS', default: true, message: 'Does it have styling?', - }, { - type: 'confirm', - name: 'wantMessages', - default: true, - message: 'Do you want i18n messages (i.e. will this component use text)?', }], actions: (data) => { // Generate index.js and index.test.js diff --git a/packages/strapi-helper-plugin/lib/internals/generators/container/index.js b/packages/strapi-helper-plugin/lib/internals/generators/container/index.js index c2224e5428..004119d553 100644 --- a/packages/strapi-helper-plugin/lib/internals/generators/container/index.js +++ b/packages/strapi-helper-plugin/lib/internals/generators/container/index.js @@ -47,11 +47,6 @@ module.exports = { name: 'wantSagas', default: true, message: 'Do you want sagas for asynchronous flows? (e.g. fetching data)', - }, { - type: 'confirm', - name: 'wantMessages', - default: true, - message: 'Do you want i18n messages (i.e. will this component use text)?', }], actions: (data) => { // Expose `pluginId` value diff --git a/packages/strapi-helper-plugin/lib/internals/generators/index.js b/packages/strapi-helper-plugin/lib/internals/generators/index.js index a029c4adfd..9603667be7 100644 --- a/packages/strapi-helper-plugin/lib/internals/generators/index.js +++ b/packages/strapi-helper-plugin/lib/internals/generators/index.js @@ -10,13 +10,11 @@ const path = require('path'); const componentGenerator = require('./component/index.js'); const containerGenerator = require('./container/index.js'); const routeGenerator = require('./route/index.js'); -const languageGenerator = require('./language/index.js'); module.exports = (plop) => { plop.setGenerator('component', componentGenerator); plop.setGenerator('container', containerGenerator); plop.setGenerator('route', routeGenerator); - plop.setGenerator('language', languageGenerator); plop.addHelper('directory', (comp) => { try { fs.accessSync(`${path.resolve(process.cwd(), 'admin', 'src', 'containers', comp)}`, fs.F_OK); diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/add-locale-data.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/add-locale-data.hbs deleted file mode 100644 index 80727c73cd..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/add-locale-data.hbs +++ /dev/null @@ -1 +0,0 @@ -$1addLocaleData({{language}}LocaleData); diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/app-locale.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/app-locale.hbs deleted file mode 100644 index 9e99e845f8..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/app-locale.hbs +++ /dev/null @@ -1,2 +0,0 @@ -$1 - '{{language}}', diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/format-translation-messages.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/format-translation-messages.hbs deleted file mode 100644 index 74c78b4632..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/format-translation-messages.hbs +++ /dev/null @@ -1 +0,0 @@ -$1 {{language}}: formatTranslationMessages({{language}}TranslationMessages), diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/index.js b/packages/strapi-helper-plugin/lib/internals/generators/language/index.js deleted file mode 100644 index dd9561dad8..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Language Generator - */ -const exec = require('child_process').exec; - -module.exports = { - description: 'Add a langauge', - prompts: [{ - type: 'input', - name: 'language', - message: 'What is the language you want to add i18n support for (e.g. "fr", "de")?', - default: 'fr', - validate: (value) => { - if ((/.+/).test(value) && value.length === 2) { - return true; - } - - return '2 character language specifier is required'; - }, - }], - - actions: () => { - const actions = []; - actions.push({ - type: 'modify', - path: '../../../../../admin/src/i18n.js', - pattern: /('react-intl\/locale-data\/[a-z]+';\n)(?!.*'react-intl\/locale-data\/[a-z]+';)/g, - templateFile: './language/intl-locale-data.hbs', - }); - actions.push({ - type: 'modify', - path: '../../../../../admin/src/i18n.js', - pattern: /([\n\s'[a-z]+',)(?!.*[\n\s'[a-z]+',)/g, - templateFile: './language/src-locale.hbs', - }); - actions.push({ - type: 'modify', - path: '../../../../../admin/src/i18n.js', - pattern: /(from\s'.\/translations\/[a-z]+.json';\n)(?!.*from\s'.\/translations\/[a-z]+.json';)/g, - templateFile: './language/translation-messages.hbs', - }); - actions.push({ - type: 'modify', - path: '../../../../../admin/src/i18n.js', - pattern: /(addLocaleData\([a-z]+LocaleData\);\n)(?!.*addLocaleData\([a-z]+LocaleData\);)/g, - templateFile: './language/add-locale-data.hbs', - }); - actions.push({ - type: 'modify', - path: '../../../../../admin/src/i18n.js', - pattern: /([a-z]+:\sformatTranslationMessages\([a-z]+TranslationMessages\),\n)(?!.*[a-z]+:\sformatTranslationMessages\([a-z]+TranslationMessages\),)/g, - templateFile: './language/format-translation-messages.hbs', - }); - actions.push({ - type: 'add', - path: '../../../../../admin/src/translations/{{language}}.json', - templateFile: './language/translations-json.hbs', - abortOnFail: true, - }); - actions.push({ - type: 'modify', - path: '../../../../../admin/src/app.js', - pattern: /(System\.import\('intl\/locale-data\/jsonp\/[a-z]+\.js'\),\n)(?!.*System\.import\('intl\/locale-data\/jsonp\/[a-z]+\.js'\),)/g, - templateFile: './language/polyfill-intl-locale.hbs', - }); - actions.push( - () => { - const cmd = 'npm run extract-intl'; - exec(cmd, (err, result, stderr) => { - if (err || stderr) { - throw err || stderr; - } - process.stdout.write(result); - }); - } - ); - - return actions; - }, -}; diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/intl-locale-data.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/intl-locale-data.hbs deleted file mode 100644 index b790a1333f..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/intl-locale-data.hbs +++ /dev/null @@ -1 +0,0 @@ -$1import {{language}}LocaleData from 'react-intl/locale-data/{{language}}'; diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/polyfill-intl-locale.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/polyfill-intl-locale.hbs deleted file mode 100644 index ea1586e7ed..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/polyfill-intl-locale.hbs +++ /dev/null @@ -1 +0,0 @@ -$1 System.import('intl/locale-data/jsonp/{{language}}.js'), diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/translation-messages.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/translation-messages.hbs deleted file mode 100644 index 0682d22ed0..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/translation-messages.hbs +++ /dev/null @@ -1 +0,0 @@ -$1import {{language}}TranslationMessages from './translations/{{language}}.json'; diff --git a/packages/strapi-helper-plugin/lib/internals/generators/language/translations-json.hbs b/packages/strapi-helper-plugin/lib/internals/generators/language/translations-json.hbs deleted file mode 100644 index fe51488c70..0000000000 --- a/packages/strapi-helper-plugin/lib/internals/generators/language/translations-json.hbs +++ /dev/null @@ -1 +0,0 @@ -[]