Skip to content

Commit

Permalink
Fixes facebook#104 by providing a useful error message.
Browse files Browse the repository at this point in the history
 Next step will be to run 'write-translations' on 'yarn start' and 'yarn build' (facebook#119)
  • Loading branch information
ericnakagawa authored and JoelMarcey committed Oct 6, 2017
1 parent a1810c9 commit 8ac191a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/server/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ function setLanguage(lang) {
}

function translate(str) {
if (
!translation[language] ||
!translation[language]["pages-strings"] ||
!translation[language]["pages-strings"][str]
) {
throw new Error(
"Text that you've identified for translation hasn't been added to the global list in 'en.json'. To solve this problem run 'yarn write-translations'."
);
}
console.log(translation[language]);
console.log(translation[language]["pages-strings"]);
console.log(translation[language]["pages-strings"][str]);
return parseEscapeSequences(translation[language]["pages-strings"][str]);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/write-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function writeFileAndCreateFolder(file, content) {
}

function execute() {
console.log("Writing translation files...");

let translations = {
"localized-strings": {
next: "Next",
Expand Down

0 comments on commit 8ac191a

Please sign in to comment.