]> git.proxmox.com Git - pve-manager.git/commitdiff
start i18n support
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Nov 2011 12:54:23 +0000 (13:54 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 21 Nov 2011 11:57:11 +0000 (12:57 +0100)
Makefile
www/manager/Utils.js
www/manager/index.pl
www/manager/pve-lang-de.js [new file with mode: 0644]
www/manager/qemu/Config.js
www/manager/window/LoginWindow.js
xgettext.pl

index 18dae5d2688f55bbfa03fdb78477e4885c1393de..b9a7888a81c20c3f5607d5b178ac97ea2681cfe3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ include defines.mk
 DESTDIR=
 
 #SUBDIRS = bin lib www aplinfo
-SUBDIRS = aplinfo PVE bin www
+SUBDIRS = aplinfo PVE bin www po
 
 DEB=${PACKAGE}_${VERSION}-${PACKAGERELEASE}_all.deb
 
index 8fd8fcf9136a87a1c1f41defa39079341110574e..6b00c68d28847990f5e182e379fde61b2ad07083 100644 (file)
@@ -182,7 +182,8 @@ Ext.define('PVE.Utils', { statics: {
 
     language_map: {
        en: 'English',
-       de: 'German'
+       de: 'German',
+       fr: 'French'
     },
 
     render_language: function (value) {
index 8e541071a4ed076aa2da27415c2b62a0779dca09..82c6bb7653ca8354854ad39ebfb6b76cb50f8877 100644 (file)
@@ -25,10 +25,19 @@ sub send_output {
 # NOTE: Requests to this page are not authenticated
 # so we must be very careful here 
 
+my $lang = 'en';
+
 my $r = Apache2::RequestUtil->request();
 my $username;
 my $token = 'null';
 if (my $cookie = $r->headers_in->{Cookie}) {
+
+    if (my $newlang = ($cookie =~ /(?:^|\s)PVELangCookie=([^;]*)/)[0]) {
+       if ($newlang =~ m/^[a-f]{2,3}(_A-F{2,3})?$/) {
+           $lang = $newlang;
+       }
+    }
+
     my $ticket = PVE::REST::extract_auth_cookie($cookie);
     if (($username = PVE::AccessControl::verify_ticket($ticket, 1))) {
        $token = PVE::AccessControl::assemble_csrf_prevention_token($username);
@@ -48,6 +57,20 @@ if (!PVE) PVE = {};
 PVE.GUIVersion = '$version';
 PVE.UserName = '$username';
 PVE.CSRFPreventionToken = '$token';
+_EOJS
+
+my $langfile = "/usr/share/pve-manager/ext4/locale/ext-lang-${lang}.js";
+$jssrc .= PVE::Tools::file_get_contents($langfile) if -f $langfile;
+
+my $i18nsrc;
+$langfile = "/usr/share/pve-manager/root/pve-lang-${lang}.js";
+if (-f $langfile) {
+    $i18nsrc = PVE::Tools::file_get_contents($langfile);
+} else {
+    $i18nsrc = 'function gettext(buf) { return buf; }';
+}
+
+$jssrc .= <<_EOJS;
 
 Ext.require(['*', '$workspace']);
 
@@ -60,8 +83,6 @@ Ext.onReady(function() { Ext.create('$workspace');});
 
 _EOJS
 
-$jssrc .= "";
-
 my $page = <<_EOD;
 <html>
   <head>
@@ -72,9 +93,9 @@ my $page = <<_EOD;
     <link rel="stylesheet" type="text/css" href="/pve2/ext4/resources/css/ext-all.css" />
     <link rel="stylesheet" type="text/css" href="/pve2/css/ext-pve.css" />
  
+    <script type="text/javascript">$i18nsrc</script>
     <script type="text/javascript" src="/pve2/ext4/ext-all-debug.js"></script>
     <script type="text/javascript" src="/pve2/ext4/pvemanagerlib.js"></script>
-    
     <script type="text/javascript">$jssrc</script>
     
   </head>
diff --git a/www/manager/pve-lang-de.js b/www/manager/pve-lang-de.js
new file mode 100644 (file)
index 0000000..a81dad9
--- /dev/null
@@ -0,0 +1,4 @@
+Ext.onReady(function() {
+    // fixme: how do we implement i18n?
+    //alert("LOADED LANG DE");
+});
\ No newline at end of file
index 7951f8fab86cd1468e0d3ae0124c03c845bd12d8..908c770ee209f4a967a314757ef904e6149fe429 100644 (file)
@@ -68,7 +68,7 @@ Ext.define('PVE.qemu.Config', {
        });
 
        var shutdownBtn = Ext.create('PVE.button.Button', {
-           text: 'Shutdown',
+           text: gettext('Shutdown'),
            confirmMsg: "Do you really want to shutdown the VM?",
            handler: function() {
                vm_command('shutdown', { timeout: 30 });
index e3ea4fa374c50da24244f25c0ca5311cc673487e..a3b12c39c9a9c7c7cfc713e36a2058f4fa63b2c3 100644 (file)
@@ -41,7 +41,7 @@ Ext.define('PVE.window.LoginWindow', {
            closable: false,
            resizable: false,
            layout: 'auto',
-           title: 'Proxmox VE Login',
+           title: gettext('Proxmox VE Login'),
 
            items: [{
                xtype: 'form',
@@ -49,7 +49,6 @@ Ext.define('PVE.window.LoginWindow', {
                url: '/api2/extjs/access/ticket',
 
                fieldDefaults: {
-                   labelWidth: 70,
                    labelAlign: 'right'
                },
 
@@ -61,9 +60,9 @@ Ext.define('PVE.window.LoginWindow', {
                items: [
                    { 
                        xtype: 'textfield', 
-                       fieldLabel: 'User name'
+                       fieldLabel: gettext('User name')
                        name: 'username',
-                       blankText: "Enter your user name",
+                       blankText: gettext("Enter your user name"),
                        listeners: {
                            afterrender: function(f) {
                                // Note: only works if we pass delay 1000
@@ -84,9 +83,9 @@ Ext.define('PVE.window.LoginWindow', {
                    { 
                        xtype: 'textfield', 
                        inputType: 'password',
-                       fieldLabel: 'Password'
+                       fieldLabel: gettext('Password')
                        name: 'password',
-                       blankText: "Enter your password",
+                       blankText: gettext("Enter your password"),
                        listeners: {
                            specialkey: function(field, e) {
                                if (e.getKey() === e.ENTER) {
@@ -98,11 +97,25 @@ Ext.define('PVE.window.LoginWindow', {
                    {
                        xtype: 'pveRealmComboBox',
                        name: 'realm'
+                   },
+                   {   
+                       xtype: 'pveLanguageSelector',
+                       fieldLabel: gettext('Language'), 
+                       value: Ext.util.Cookies.get('PVELangCookie') || 'en',
+                       name: 'lang',
+                       submitValue: false,
+                       listeners: {
+                           change: function(t, value) {
+                               var dt = Ext.Date.add(new Date(), Ext.Date.YEAR, 10);
+                               Ext.util.Cookies.set('PVELangCookie', value, dt);
+                               window.location.reload();
+                           }
+                       }
                    }
                ],
                buttons: [
                    {
-                       text: 'Login',
+                       text: gettext('Login'),
                        handler: function(){
                            me.onLogon();
                        }
index 33b83f504ac470c5f18e56d987df965f2fb9b09c..9f55a6f17ad9fda54259612a32c2c73cb47cbff3 100755 (executable)
@@ -57,21 +57,19 @@ my $ctime = scalar localtime;
 
 my $header = << '.';
 # SOME DESCRIPTIVE TITLE.
-# Copyright (C) 2008 Proxmox Server Solutions GmbH
+# Copyright (C) 2011 Proxmox Server Solutions GmbH
 # This file is distributed under the same license as the pve-manager package.
-# Proxmox Support Team <support@proxmox.com>, 2008.
+# Proxmox Support Team <support@proxmox.com>, 2011.
 #
-#, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: pve-manager 2\n"
 .
 
 $header .= "\"Report-Msgid-Bugs-To: $opts{'msgid-bugs-address'}\\n\"\n" if  $opts{'msgid-bugs-address'};
 $header .= "\"POT-Creation-Date: $ctime\\n\"\n";
 
 $header .= << '.';
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <support@proxmox.com>\n"
 "MIME-Version: 1.0\n"