]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - Utils.js
add GaugeWidget from PVE
[proxmox-widget-toolkit.git] / Utils.js
index 79d0dc0ad14ff65a03c6e3c19430b32058203aa1..93cba81ee8798f5c76daa57df753a82351a373f4 100644 (file)
--- a/Utils.js
+++ b/Utils.js
@@ -1,9 +1,9 @@
 Ext.ns('Proxmox');
 Ext.ns('Proxmox.Setup');
 
-// TODO: implement gettext
-function gettext(buf) { return buf; }
-
+if (!Ext.isFunction(gettext)) {
+    function gettext(buf) { return buf; }
+}
 
 if (!Ext.isDefined(Proxmox.Setup.auth_cookie_name)) {
     throw "Proxmox library not initialized";
@@ -60,10 +60,33 @@ Ext.define('Proxmox.Utils', { utilities: {
     stateText: gettext('State'),
     groupText: gettext('Group'),
 
-    communityText: gettext('Community'),
-    basicText: gettext('Basic'),
-    standardText: gettext('Standard'),
-    premiumText: gettext('Premium'),
+    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
@@ -143,13 +166,13 @@ Ext.define('Proxmox.Utils', { utilities: {
 
     format_subscription_level: function(level) {
        if (level === 'c') {
-           return Proxmox.Utils.communityText;
+           return 'Community';
        } else if (level === 'b') {
-           return Proxmox.Utils.basicText;
+           return 'Basic';
        } else if (level === 's') {
-           return Proxmox.Utils.standardText;
+           return 'Standard';
        } else if (level === 'p') {
-           return Proxmox.Utils.premiumText;
+           return 'Premium';
        } else {
            return Proxmox.Utils.noneText;
        }