diff --git a/lib/server/translate.js b/lib/server/translate.js index 416fd1c100e0..7d46f90063b9 100644 --- a/lib/server/translate.js +++ b/lib/server/translate.js @@ -26,22 +26,26 @@ function setLanguage(lang) { language = lang; } +function doesTranslationExist(str, lang) { + return ( + translation[lang] && + translation[lang]['pages-strings'] && + translation[lang]['pages-strings'][str] + ); +} + function translate(str) { if (!language || language === '') { + // Check English, just in case; otherwise, just return the raw string back + if (doesTranslationExist(str, 'en')) { + return parseEscapeSequences(translation['en']['pages-strings'][str]); + } return str; } - if ( - !translation[language] || - !translation[language]['pages-strings'] || - !translation[language]['pages-strings'][str] - ) { + if (!doesTranslationExist(str, language)) { // if a translated string doesn't exist, but english does then fallback - if ( - translation['en'] && - translation['en']['pages-strings'] && - translation['en']['pages-strings'][str] - ) { + if (doesTranslationExist(str, 'en')) { console.error( "Could not find a string translation in '" + language +