Add language selector in static pages' footer

pull/1/head
yflory 7 years ago
parent 5887ff1a6d
commit ff17a0aad6

@ -1,10 +1,11 @@
define([
'/api/config',
'/common/hyperscript.js',
'/common/common-language.js',
'/customize/messages.js',
'jquery',
'/customize/application_config.js',
], function (Config, h, Msg, $, AppConfig) {
], function (Config, h, Language, Msg, $, AppConfig) {
var Pages = {};
var urlArgs = Config.requireConf.urlArgs;
@ -13,6 +14,25 @@ define([
return e;
};
var languageSelector = function () {
var options = [];
var languages = Msg._languages;
var selected = Msg._languageUsed;
var keys = Object.keys(languages).sort();
keys.forEach(function (l) {
var attr = { value: l };
if (selected === l) { attr.selected = 'selected'; }
options.push(h('option', attr, languages[l]));
});
var select = h('select', {}, options);
$(select).change(function () {
Language.setLanguage($(select).val() || '', null, function () {
window.location.reload();
});
});
return select;
};
var footerCol = function (title, L, literal) {
return h('div.col-6.col-sm-3', [
h('ul.list-unstyled', [
@ -47,7 +67,8 @@ define([
h('div.row', [
footerCol(null, [
h('div.cp-bio-foot', [
h('p', Msg.main_footerText)
h('p', Msg.main_footerText),
languageSelector()
])
], ''),
footerCol('footer_applications', [

Loading…
Cancel
Save