From f6f0066aff6dc732bca45b4a1d185f9c52acac06 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 4 Oct 2017 10:50:59 +0200 Subject: [PATCH] LanguageSelector.js - add language selector --- Makefile | 1 + Utils.js | 28 ++++++++++++++++++++++++++++ form/LanguageSelector.js | 6 ++++++ 3 files changed, 35 insertions(+) create mode 100644 form/LanguageSelector.js diff --git a/Makefile b/Makefile index eae57cb..5ab6817 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ JSSRC= \ form/DateTimeField.js \ form/Checkbox.js \ form/KVComboBox.js \ + form/LanguageSelector.js \ form/ComboGrid.js \ form/RRDTypeSelector.js \ button/Button.js \ diff --git a/Utils.js b/Utils.js index 97b6c75..e0c26d7 100644 --- a/Utils.js +++ b/Utils.js @@ -60,6 +60,34 @@ Ext.define('Proxmox.Utils', { utilities: { stateText: gettext('State'), groupText: gettext('Group'), + language_map: { + en: 'English', + fr: 'French', + de: 'German', + it: 'Italian', + es: 'Spanish' + }, + + render_language: function (value) { + if (!value) { + return Proxmox.Utils.defaultText + ' (English)'; + } + var text = Proxmox.Utils.language_map[value]; + if (text) { + return text + ' (' + value + ')'; + } + return value; + }, + + language_array: function() { + var data = [['__default__', Proxmox.Utils.render_language('')]]; + Ext.Object.each(Proxmox.Utils.language_map, function(key, value) { + data.push([key, Proxmox.Utils.render_language(value)]); + }); + + return data; + }, + getNoSubKeyHtml: function(url) { // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans return Ext.String.format('You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.', url || 'http://www.proxmox.com'); diff --git a/form/LanguageSelector.js b/form/LanguageSelector.js new file mode 100644 index 0000000..4444c12 --- /dev/null +++ b/form/LanguageSelector.js @@ -0,0 +1,6 @@ +Ext.define('Proxmox.form.LanguageSelector', { + extend: 'Proxmox.form.KVComboBox', + xtype: 'proxmoxLanguageSelector', + + comboItems: Proxmox.Utils.language_array() +});