Commit 35a1693a authored by JC Brand's avatar JC Brand

Use es2015 module imports in i18n.js

parent a5fdbb0e
This diff is collapsed.
......@@ -8,42 +8,38 @@
//
/*global define */
(function (root, factory) {
define([
"es6-promise/dist/es6-promise.auto",
"jed",
"./lodash.noconflict",
"moment",
'moment/locale/af',
'moment/locale/ar',
'moment/locale/bg',
'moment/locale/ca',
'moment/locale/cs',
'moment/locale/de',
'moment/locale/es',
'moment/locale/eu',
'moment/locale/fr',
'moment/locale/he',
'moment/locale/hi',
'moment/locale/hu',
'moment/locale/id',
'moment/locale/it',
'moment/locale/ja',
'moment/locale/nb',
'moment/locale/nl',
'moment/locale/pl',
'moment/locale/pt-br',
'moment/locale/ro',
'moment/locale/ru',
'moment/locale/tr',
'moment/locale/uk',
'moment/locale/zh-cn',
'moment/locale/zh-tw'
], factory);
}(this, function (Promise, Jed, _, moment) {
'use strict';
import 'moment/locale/af';
import 'moment/locale/ar';
import 'moment/locale/bg';
import 'moment/locale/ca';
import 'moment/locale/cs';
import 'moment/locale/de';
import 'moment/locale/es';
import 'moment/locale/eu';
import 'moment/locale/fr';
import 'moment/locale/he';
import 'moment/locale/hi';
import 'moment/locale/hu';
import 'moment/locale/id';
import 'moment/locale/it';
import 'moment/locale/ja';
import 'moment/locale/nb';
import 'moment/locale/nl';
import 'moment/locale/pl';
import 'moment/locale/pt-br';
import 'moment/locale/ro';
import 'moment/locale/ru';
import 'moment/locale/tr';
import 'moment/locale/uk';
import 'moment/locale/zh-cn';
import 'moment/locale/zh-tw';
import Jed from "jed";
import Promise from "es6-promise/dist/es6-promise.auto";
import _ from "./lodash.noconflict";
import moment from "moment";
function detectLocale (library_check) {
function detectLocale (library_check) {
/* Determine which locale is supported by the user's system as well
* as by the relevant library (e.g. converse.js or moment.js).
*
......@@ -70,26 +66,26 @@
locale = isLocaleAvailable(window.navigator.systemLanguage, library_check);
}
return locale || 'en';
}
}
function isMomentLocale (locale) {
function isMomentLocale (locale) {
return _.includes(moment.locales(), locale);
}
}
function isConverseLocale (locale, supported_locales) {
function isConverseLocale (locale, supported_locales) {
return _.isString(locale) && _.includes(supported_locales, locale);
}
}
function getLocale (preferred_locale, isSupportedByLibrary) {
function getLocale (preferred_locale, isSupportedByLibrary) {
if (_.isString(preferred_locale)) {
if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
return preferred_locale;
}
}
return detectLocale(isSupportedByLibrary) || 'en';
}
}
function isLocaleAvailable (locale, available) {
function isLocaleAvailable (locale, available) {
/* Check whether the locale or sub locale (e.g. en-US, en) is supported.
*
* Parameters:
......@@ -104,11 +100,11 @@
return sublocale;
}
}
}
}
let jed_instance;
let jed_instance;
return {
export default {
setLocales (preferred_locale, _converse) {
_converse.locale = getLocale(
......@@ -169,5 +165,4 @@
xhr.send();
});
}
};
}));
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment