1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Add language support

This commit is contained in:
vrde 2015-07-15 14:52:14 +02:00
parent 3ad7763577
commit 344fffad91
2 changed files with 12 additions and 6 deletions

View File

@ -104,7 +104,7 @@ let AccountSettings = React.createClass({
show={true}
defaultExpanded={true}>
{content}
<Form
{/*<Form
url={AppConstants.serverUrl + 'api/users/set_language/'}>
<Property
name='language'
@ -121,7 +121,7 @@ let AccountSettings = React.createClass({
</select>
</Property>
<hr />
</Form>
</Form>*/}
</CollapsibleParagraph>
);
}

View File

@ -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);