mirror of
https://github.com/strapi/strapi.git
synced 2025-11-23 21:53:05 +00:00
Remove i18n in plugin generators
This commit is contained in:
parent
9d11c38ac7
commit
1184bc9bf4
@ -29,11 +29,6 @@ module.exports = {
|
|||||||
name: 'wantCSS',
|
name: 'wantCSS',
|
||||||
default: true,
|
default: true,
|
||||||
message: 'Does it have styling?',
|
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) => {
|
actions: (data) => {
|
||||||
// Generate index.js and index.test.js
|
// Generate index.js and index.test.js
|
||||||
|
|||||||
@ -47,11 +47,6 @@ module.exports = {
|
|||||||
name: 'wantSagas',
|
name: 'wantSagas',
|
||||||
default: true,
|
default: true,
|
||||||
message: 'Do you want sagas for asynchronous flows? (e.g. fetching data)',
|
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) => {
|
actions: (data) => {
|
||||||
// Expose `pluginId` value
|
// Expose `pluginId` value
|
||||||
|
|||||||
@ -10,13 +10,11 @@ const path = require('path');
|
|||||||
const componentGenerator = require('./component/index.js');
|
const componentGenerator = require('./component/index.js');
|
||||||
const containerGenerator = require('./container/index.js');
|
const containerGenerator = require('./container/index.js');
|
||||||
const routeGenerator = require('./route/index.js');
|
const routeGenerator = require('./route/index.js');
|
||||||
const languageGenerator = require('./language/index.js');
|
|
||||||
|
|
||||||
module.exports = (plop) => {
|
module.exports = (plop) => {
|
||||||
plop.setGenerator('component', componentGenerator);
|
plop.setGenerator('component', componentGenerator);
|
||||||
plop.setGenerator('container', containerGenerator);
|
plop.setGenerator('container', containerGenerator);
|
||||||
plop.setGenerator('route', routeGenerator);
|
plop.setGenerator('route', routeGenerator);
|
||||||
plop.setGenerator('language', languageGenerator);
|
|
||||||
plop.addHelper('directory', (comp) => {
|
plop.addHelper('directory', (comp) => {
|
||||||
try {
|
try {
|
||||||
fs.accessSync(`${path.resolve(process.cwd(), 'admin', 'src', 'containers', comp)}`, fs.F_OK);
|
fs.accessSync(`${path.resolve(process.cwd(), 'admin', 'src', 'containers', comp)}`, fs.F_OK);
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
$1addLocaleData({{language}}LocaleData);
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
$1
|
|
||||||
'{{language}}',
|
|
||||||
@ -1 +0,0 @@
|
|||||||
$1 {{language}}: formatTranslationMessages({{language}}TranslationMessages),
|
|
||||||
@ -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;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@ -1 +0,0 @@
|
|||||||
$1import {{language}}LocaleData from 'react-intl/locale-data/{{language}}';
|
|
||||||
@ -1 +0,0 @@
|
|||||||
$1 System.import('intl/locale-data/jsonp/{{language}}.js'),
|
|
||||||
@ -1 +0,0 @@
|
|||||||
$1import {{language}}TranslationMessages from './translations/{{language}}.json';
|
|
||||||
Loading…
x
Reference in New Issue
Block a user