[Libreoffice-commits] online.git: loleaflet/src
Henry Castro
hcastro at collabora.com
Mon Nov 6 21:28:06 UTC 2017
loleaflet/src/control/Control.Menubar.js | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
New commits:
commit c4e987c3d64fcbe71d15eabd580a0f25640008a4
Author: Henry Castro <hcastro at collabora.com>
Date: Mon Nov 6 17:25:19 2017 -0400
loleaflet: sort translated languages
Change-Id: I35a7fc447939796eb33e4a8fd2df3631ec6db1ae
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 24054af5..4582b5d9 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -375,14 +375,25 @@ L.Control.Menubar = L.Control.extend({
_onInitMenu: function (e) {
if (e.commandName === '.uno:LanguageStatus' && L.Util.isArray(e.commandValues)) {
- var resetLang = _('Reset to Default Language');
+ var resetLang = _('Reset to Default Language'), translated, neutral;
+ var languages = [];
+
+ e.commandValues.forEach(function(language) {
+ languages.push({translated: _(language), neutral: language});
+ });
+ languages.sort(function(a, b) {
+ return a.translated < b.translated ? -1 : a.translated > b.translated ? 1 : 0;
+ });
+
$menuSelection = $('#menu-noneselection').parent();
$menuParagraph = $('#menu-noneparagraph').parent();
$menuDefault = $('#menu-nonelanguage').parent();
- for (var lang in e.commandValues) {
- $menuSelection.append(this._createLangMenuItem(_(e.commandValues[lang]), encodeURIComponent('Current_' + e.commandValues[lang])));
- $menuParagraph.append(this._createLangMenuItem(_(e.commandValues[lang]), encodeURIComponent('Paragraph_' + e.commandValues[lang])));
- $menuDefault.append(this._createLangMenuItem(_(e.commandValues[lang]), encodeURIComponent('Default_' + e.commandValues[lang])));
+ for (var lang in languages) {
+ translated = languages[lang].translated;
+ neutral = languages[lang].neutral;
+ $menuSelection.append(this._createLangMenuItem(translated, encodeURIComponent('Current_' + neutral)));
+ $menuParagraph.append(this._createLangMenuItem(translated, encodeURIComponent('Paragraph_' + neutral)));
+ $menuDefault.append(this._createLangMenuItem(translated, encodeURIComponent('Default_' + neutral)));
}
$menuSelection.append(this._createMenu([{type: 'separator'}]));
$menuParagraph.append(this._createMenu([{type: 'separator'}]));
More information about the Libreoffice-commits
mailing list