Permalink
Browse files

Fix language list ordering

  • Loading branch information...
1 parent 09a6534 commit 756fa0795aac11d01555d9bf8930a25ede4b1fa4 @cdujeu cdujeu committed Sep 5, 2016
@@ -33,13 +33,13 @@ Class.create("AjxpInstaller", AjxpPane, {
initLanguageSwitcher: function(){
var selector = this.htmlElement.down("#installer_lang");
- $H(ajxpBootstrap.parameters.get('availableLanguages')).each(function(pair){
- var option = new Element('option', {value:pair.key}).update(pair.value);
- if(pair.key == ajaxplorer.currentLanguage){
- option.writeAttribute("selected", "true");
- }
- selector.insert(option);
- });
+ if(!selector.down('option')){
+ pydio.listLanguagesWithCallback(function(key, label, selected){
+ var option = new Element('option', {value:key}).update(label);
+ if(selected) option.writeAttribute("selected", "true");
+ selector.insert(option);
+ });
+ }
selector.observe("change", function(){
pydio.fire("language_changed");
pydio.currentLanguage = selector.getValue();
@@ -446,10 +446,9 @@
if(pydio.user) var userLang = pydio.user.getPreference("lang");
if(!userLang) userLang = window.ajxpBootstrap.parameters.get("currentLanguage");
var selector = $(oForm).select('select[id="language_selector"]')[0];
- var languages = $H(window.ajxpBootstrap.parameters.get("availableLanguages"));
- languages.each(function(pair){
- var option = new Element('option', {value:pair.key,id:'lang_'+pair.key});
- option.update(pair.value);
+ pydio.listLanguagesWithCallback(function(key, label){
+ var option = new Element('option', {value:key,id:'lang_'+key});
+ option.update(label);
selector.insert(option);
});
selector.setValue(userLang);
@@ -342,6 +342,14 @@ class Pydio extends Observable{
return this.Registry.getPluginConfigs(pluginQuery);
}
+ listLanguagesWithCallback(callback){
+ let langs = this.Parameters.get("availableLanguages") || {"en":"Default"};
+ let current = this.currentLanguage;
+ Object.keys(langs).sort().map(function(key){
+ callback(key, langs[key], (current === key));
+ });
+ }
+
/**
* Reload all messages from server and trigger updateI18nTags
* @param newLanguage String
@@ -139,9 +139,9 @@ Class.create("FormManager", {
conn.onComplete = function(transport){
element.removeClassName('SF_inlineButtonWorking');
if(transport.responseText.startsWith('SUCCESS:')){
- ajaxplorer.displayMessage("SUCCESS", transport.responseText.replace("SUCCESS:", ""));
+ pydio.displayMessage("SUCCESS", transport.responseText.replace("SUCCESS:", ""));
}else{
- ajaxplorer.displayMessage("ERROR", transport.responseText.replace("ERROR:", ""));
+ pydio.displayMessage("ERROR", transport.responseText.replace("ERROR:", ""));
}
element.siblings().each(function(el){
if(el.pe) el.pe.onTimerEvent();
@@ -215,17 +215,14 @@ Class.create("FormManager", {
choices = ["loading|"+MessageHash[466]+"..."];
json_file = param.get("choices").split(":")[1];
}else if(param.get("choices") == "AJXP_AVAILABLE_LANGUAGES"){
- var object = window.ajxpBootstrap.parameters.get("availableLanguages");
choices = [];
- for(key in object){
- if(object.hasOwnProperty(key)){
- choices.push(key + "|" + object[key]);
- }
- }
+ pydio.listLanguagesWithCallback(function(key, label){
+ choices.push(key + '|' + label);
+ });
}else if(param.get("choices") == "AJXP_AVAILABLE_REPOSITORIES"){
choices = [];
- if(ajaxplorer.user){
- ProtoCompat.map2hash(ajaxplorer.user.repositories).each(function(pair){
+ if(pydio.user){
+ ProtoCompat.map2hash(pydio.user.repositories).each(function(pair){
choices.push(pair.value.getId() + '|' + pair.value.getLabel());
});
}
@@ -143,12 +143,9 @@
this.setState({choices:newOutput});
}.bind(this));
}else if(choices == "AJXP_AVAILABLE_LANGUAGES"){
- var object = global.pydio.Parameters.get("availableLanguages");
- for(var key in object){
- if(object.hasOwnProperty(key)){
- output.set(key, object[key]);
- }
- }
+ global.pydio.listLanguagesWithCallback(function(key, label){
+ output.set(key, label);
+ });
}else if(choices == "AJXP_AVAILABLE_REPOSITORIES"){
if(global.pydio.user){
global.pydio.user.repositories.forEach(function(repository){

0 comments on commit 756fa07

Please sign in to comment.