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

Use js-utility-belt's language utils

This commit is contained in:
Brett Sun 2016-06-13 15:05:53 +02:00
parent 63310c5717
commit 5a270442cb

View File

@ -1,17 +1,11 @@
'use strict';
import { getBrowserLang } from 'js-utility-belt/es6/lang';
import languages from '../constants/languages';
import { formatText } from './general';
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
@ -19,7 +13,7 @@ export function getLang() {
* @return {string} The formated string
*/
export function getLangText(s, ...args) {
let lang = getLang();
const lang = getBrowserLang();
try {
if(lang in languages) {
return formatText(languages[lang][s], ...args);