Skip to content

Commit

Permalink
[i18n] fix i18nrc parsing (#41741)
Browse files Browse the repository at this point in the history
* check for translations in file

* update template
  • Loading branch information
Bamieh authored Jul 23, 2019
1 parent 2eb25c2 commit 131e4c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"paths": {
"<%= camelCase(name) %>": "./"
}
},
"translations": [
"translations/zh-CN.json"
]
}
10 changes: 6 additions & 4 deletions src/legacy/server/i18n/get_translations_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export async function getTranslationPaths({ cwd, glob }) {
try {
const content = await readFileAsync(entryFullPath, 'utf8');
const { translations } = JSON.parse(content);
translations.forEach(translation => {
const translationFullPath = resolve(pluginBasePath, translation);
translationPaths.push(translationFullPath);
});
if (translations && translations.length) {
translations.forEach(translation => {
const translationFullPath = resolve(pluginBasePath, translation);
translationPaths.push(translationFullPath);
});
}
} catch (err) {
throw new Error(`Failed to parse .i18nrc.json file at ${entryFullPath}`);
}
Expand Down

0 comments on commit 131e4c2

Please sign in to comment.