fix #1393: use language from datacenter.cfg for gui

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@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-08-17 09:26:21 +02:00 committed by Dietmar Maurer
parent 03bb5ce933
commit f4aa76c549
3 changed files with 9 additions and 2 deletions

View File

@ -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;

View File

@ -26,6 +26,7 @@
<script type="text/javascript">
Proxmox = {
Setup: { auth_cookie_name: 'PVEAuthCookie' },
defaultLang: '[% lang %]',
UserName: '[% username %]',
CSRFPreventionToken: '[% token %]'
};

View File

@ -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