From 344fffad91c142fd382bfb315092696d28077016 Mon Sep 17 00:00:00 2001 From: vrde Date: Wed, 15 Jul 2015 14:52:14 +0200 Subject: [PATCH] Add language support --- js/components/settings_container.js | 6 +++--- js/utils/lang_utils.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/components/settings_container.js b/js/components/settings_container.js index 5308c732..24dcbc9b 100644 --- a/js/components/settings_container.js +++ b/js/components/settings_container.js @@ -104,7 +104,7 @@ let AccountSettings = React.createClass({ show={true} defaultExpanded={true}> {content} -

-
+ */} ); } @@ -346,4 +346,4 @@ let APISettings = React.createClass({ } }); -export default SettingsContainer; \ No newline at end of file +export default SettingsContainer; diff --git a/js/utils/lang_utils.js b/js/utils/lang_utils.js index c0a42d98..bec4c66d 100644 --- a/js/utils/lang_utils.js +++ b/js/utils/lang_utils.js @@ -4,6 +4,14 @@ import languages from '../constants/languages'; import { formatText } from './general_utils'; + +export function getLang() { + // this is just for testing, as changing the navigator.language wasn't possible + // return 'fr'; + return navigator.languages ? navigator.languages[0] : + (navigator.language || navigator.userLanguage); +} + /** * Is used to translate strings to another language. Basically can be used with C's string format method. * @param {string} s The string you want to translate @@ -11,9 +19,7 @@ import { formatText } from './general_utils'; * @return {string} The formated string */ export function getLangText(s, ...args) { - let lang = navigator.language || navigator.userLanguage; - // this is just for testing, as changing the navigator.language wasn't possible - //ang = 'de'; + let lang = getLang(); try { if(lang in languages) { return formatText(languages[lang][s], args);