Skip to content

Commit

Permalink
generate default translations file
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 17, 2020
1 parent 8c9ba4a commit c6a784c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions packages/kbn-plugin-generator/sao_template/sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ async function gitInit(dir) {
}
}

async function generateDefaultI18nMessages(dir) {
try {
await execa('node', [
'scripts/i18n_extract',
'--output-dir',
`${dir}/translations`,
'--include-config',
`${dir}/.i18nrc.json`,
`--path=${dir}`,
]);
console.log(`Default translation messages generated in ${dir}`);
} catch (error) {
console.error(error);
throw new Error(`Failure to generate default translations ${dir}: ${error.all || error}`);
}
}

async function moveToCustomFolder(from, to) {
try {
await execa('mv', [from, to]);
Expand Down Expand Up @@ -161,6 +178,10 @@ module.exports = function({ name, targetPath }) {
} else {
// Init git only in the default path
await gitInit(dir);

if (answers.generateTranslations) {
await generateDefaultI18nMessages(dir);
}
}

// Apply eslint to the generated plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,13 @@
}
}
},
"messages": {}
"messages": {
"<%= camelCase(name) %>.buttonText": "Translate me to Japanese",
"<%= camelCase(name) %>.congratulationsTitle": "",
"<%= camelCase(name) %>.content": "",
"<%= camelCase(name) %>.dataUpdated": "",
"<%= camelCase(name) %>.greetingText": "",
"<%= camelCase(name) %>.helloWorldText": "",
"<%= camelCase(name) %>.timestampText": ""
}
}

0 comments on commit c6a784c

Please sign in to comment.