[pve-devel] [PATCH manager] fix #1393: use language from datacenter.cfg for gui
Dietmar Maurer
dietmar at proxmox.com
Fri Aug 17 10:38:38 CEST 2018
>From PVE::Cluster:
language => {
optional => 1,
type => 'string',
description => "Default GUI language.",
enum => [ 'en', 'de' ],
},
But we have more languages!
> On August 17, 2018 at 9:26 AM Dominik Csapak <d.csapak at proxmox.com> wrote:
>
>
> if we do not have a language cookie, try to read
> the language from the datacenter.cfg and fall back to 'en'
>
> also set it into the 'Proxmox' object, so that the gui can show it
> in the LoginWindow
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> PVE/Service/pveproxy.pm | 8 +++++++-
> www/index.html.tpl | 1 +
> www/manager6/window/LoginWindow.js | 2 +-
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
> index b092438a..bb60b29e 100755
> --- a/PVE/Service/pveproxy.pm
> +++ b/PVE/Service/pveproxy.pm
> @@ -10,6 +10,7 @@ use Encode;
> use URI;
> use URI::QueryParam;
> use Data::Dumper;
> +use PVE::Cluster;
> use PVE::API2Tools;
> use PVE::API2;
> use PVE::APIServer::Formatter;
> @@ -176,7 +177,7 @@ sub is_phone {
> sub get_index {
> my ($nodename, $server, $r, $args) = @_;
>
> - my $lang = 'en';
> + my $lang;
> my $username;
> my $token = 'null';
>
> @@ -192,6 +193,11 @@ sub get_index {
> }
> }
>
> + if (!$lang) {
> + my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
> + $lang = $dc_conf->{language} // 'en';
> + }
> +
> $username = '' if !$username;
>
> my $mobile = is_phone($r->header('User-Agent')) ? 1 : 0;
> diff --git a/www/index.html.tpl b/www/index.html.tpl
> index a972e3aa..ae7f610f 100644
> --- a/www/index.html.tpl
> +++ b/www/index.html.tpl
> @@ -26,6 +26,7 @@
> <script type="text/javascript">
> Proxmox = {
> Setup: { auth_cookie_name: 'PVEAuthCookie' },
> + defaultLang: '[% lang %]',
> UserName: '[% username %]',
> CSRFPreventionToken: '[% token %]'
> };
> diff --git a/www/manager6/window/LoginWindow.js
> b/www/manager6/window/LoginWindow.js
> index 683fb54c..3ab5173c 100644
> --- a/www/manager6/window/LoginWindow.js
> +++ b/www/manager6/window/LoginWindow.js
> @@ -164,7 +164,7 @@ Ext.define('PVE.window.LoginWindow', {
> {
> xtype: 'proxmoxLanguageSelector',
> fieldLabel: gettext('Language'),
> - value: Ext.util.Cookies.get('PVELangCookie') || 'en',
> + value: Ext.util.Cookies.get('PVELangCookie') || Proxmox.defaultLang ||
> 'en',
> name: 'lang',
> reference: 'langField',
> submitValue: false
> --
> 2.11.0
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list