From 777857b50cee1a32f12efad06b71913ad601de65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 2 Jun 2015 12:00:59 +0200 Subject: [PATCH] include lodash.templates --- js/utils/lang_utils.js | 17 +++++++++++------ package.json | 5 +++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/js/utils/lang_utils.js b/js/utils/lang_utils.js index b7a7681e..a936294e 100644 --- a/js/utils/lang_utils.js +++ b/js/utils/lang_utils.js @@ -1,12 +1,17 @@ import languages from '../constants/languages'; +import template from 'lodash.template'; -let getText = function(s) { +let getText = function(s, ...args) { let lang = navigator.language || navigator.userLanguage; - if(lang in languages && s in languages[lang]) { - return languages[lang][s]; - } else { - throw new Error('Your language is not supported.'); - // How ironic that this error is thrown in the english language... + try { + if(lang in languages) { + return languages[lang][s]; + } else { + // just use the english language + return languages['en-US'][s]; + } + } catch(err) { + console.error(err); } }; diff --git a/package.json b/package.json index 38710b47..3007fdf4 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,12 @@ "alt": "^0.16.5", "classnames": "^1.2.2", "isomorphic-fetch": "^2.0.2", + "lodash.template": "^3.6.1", "object-assign": "^2.0.0", "react": "^0.13.2", + "react-bootstrap": "~0.22.6", "react-router": "^0.13.3", - "uglifyjs": "^2.4.10", - "react-bootstrap": "~0.22.6" + "uglifyjs": "^2.4.10" }, "jest": { "scriptPreprocessor": "node_modules/babel-jest",