Improve Manager lang selection to use browser preferences (#1584)
This commit is contained in:
parent
e08d0a78e6
commit
6cffe855a2
|
@ -35,14 +35,19 @@ llapp.provider '$translator', ->
|
|||
if navigator.languages
|
||||
nlangs = navigator.languages
|
||||
for nl in nlangs
|
||||
console.log 'Navigator lang', nl
|
||||
for al in window.availableLanguages
|
||||
if al == nl
|
||||
console.log ' Available lang', al
|
||||
re = new RegExp('^'+al+'-?')
|
||||
if nl.match re
|
||||
console.log ' Matching lang =', al
|
||||
langs.push al
|
||||
else if al.substring(0, 1) == nl.substring(0, 1)
|
||||
langs2.push al
|
||||
res.lang = if langs[0] then langs[0] else if langs2[0] then langs2[0] else 'en'
|
||||
else
|
||||
res.lang = 'en'
|
||||
console.log 'Selected lang ->', res.lang
|
||||
|
||||
# Internal properties
|
||||
res.deferredTr = []
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.10.0
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
LemonLDAP::NG base app module
|
||||
|
@ -17,7 +17,7 @@ LemonLDAP::NG base app module
|
|||
llapp = angular.module('llApp', ['ngAria']);
|
||||
|
||||
llapp.provider('$translator', function() {
|
||||
var al, c, j, k, langs, langs2, len, len1, nl, nlangs, ref, res;
|
||||
var al, c, j, k, langs, langs2, len, len1, nl, nlangs, re, ref, res;
|
||||
res = {};
|
||||
c = decodeURIComponent(document.cookie);
|
||||
if (c.match(/llnglanguage=(\w+)/)) {
|
||||
|
@ -31,10 +31,14 @@ LemonLDAP::NG base app module
|
|||
}
|
||||
for (j = 0, len = nlangs.length; j < len; j++) {
|
||||
nl = nlangs[j];
|
||||
console.log('Navigator lang', nl);
|
||||
ref = window.availableLanguages;
|
||||
for (k = 0, len1 = ref.length; k < len1; k++) {
|
||||
al = ref[k];
|
||||
if (al === nl) {
|
||||
console.log(' Available lang', al);
|
||||
re = new RegExp('^' + al + '-?');
|
||||
if (nl.match(re)) {
|
||||
console.log(' Matching lang =', al);
|
||||
langs.push(al);
|
||||
} else if (al.substring(0, 1) === nl.substring(0, 1)) {
|
||||
langs2.push(al);
|
||||
|
@ -45,6 +49,7 @@ LemonLDAP::NG base app module
|
|||
} else {
|
||||
res.lang = 'en';
|
||||
}
|
||||
console.log('Selected lang ->', res.lang);
|
||||
res.deferredTr = [];
|
||||
res.translationFields = {};
|
||||
res.translate = function(s) {
|
||||
|
@ -153,7 +158,7 @@ LemonLDAP::NG base app module
|
|||
restrict: 'E',
|
||||
terminal: true,
|
||||
compile: function(element, attr) {
|
||||
var e, error, t;
|
||||
var e, t;
|
||||
if (t = attr.type.match(/text\/(menu|parameters)/)) {
|
||||
try {
|
||||
return $htmlParams.set(t[1], JSON.parse(element[0].text));
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user