From d8b55fffa41c0d1bd29fe2b906fcc92f4f0e24ea Mon Sep 17 00:00:00 2001 From: Eric Nakagawa Date: Thu, 19 Oct 2017 16:41:20 -0700 Subject: [PATCH] Fall back to English when strings are missing (#151) --- lib/server/translate.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/server/translate.js b/lib/server/translate.js index 5c95daca7c..07eafd5378 100644 --- a/lib/server/translate.js +++ b/lib/server/translate.js @@ -32,6 +32,22 @@ function translate(str) { !translation[language]["pages-strings"] || !translation[language]["pages-strings"][str] ) { + // if a translated string doesn't exist, but english does then fallback + if ( + translation["en"] && + translation["en"]["pages-strings"] && + translation["en"]["pages-strings"][str] + ) { + console.error( + "Could not find a string translation in '" + + language + + "' for string '" + + str + + "'. Using English version instead." + ); + + return parseEscapeSequences(translation["en"]["pages-strings"][str]); + } throw new Error( "Text that you've identified for translation ('" + str +