Allow the user to select their own preferred language (#1263)

This commit is contained in:
Alex Tselegidis 2022-05-20 18:13:26 +02:00
parent ffb19f113a
commit 905dd59425
9 changed files with 75 additions and 3 deletions

View File

@ -73,6 +73,7 @@ class Accounts {
'user_email' => $user['email'],
'username' => $username,
'timezone' => ! empty($user['timezone']) ? $user['timezone'] : $default_timezone,
'language' => ! empty($user['language']) ? $user['language'] : Config::LANGUAGE,
'role_slug' => $role['slug'],
];
}

View File

@ -132,6 +132,20 @@
</select>
</div>
<div class="mb-3">
<label class="form-label" for="language">
<?= lang('language') ?>
<span class="text-danger" hidden>*</span>
</label>
<select id="language" class="form-control required">
<?php foreach (vars('available_languages') as $available_language): ?>
<option value="<?= $available_language ?>">
<?= ucfirst($available_language) ?>
</option>
<?php endforeach ?>
</select>
</div>
<div class="mb-3">
<label class="form-label" for="timezone">
<?= lang('timezone') ?>

View File

@ -171,6 +171,20 @@
</select>
</div>
<div class="mb-3">
<label class="form-label" for="language">
<?= lang('language') ?>
<span class="text-danger" hidden>*</span>
</label>
<select id="language" class="form-control required" disabled>
<?php foreach (vars('available_languages') as $available_language): ?>
<option value="<?= $available_language ?>">
<?= ucfirst($available_language) ?>
</option>
<?php endforeach ?>
</select>
</div>
<div class="mb-3">
<label class="form-label" for="timezone">
<?= lang('timezone') ?>

View File

@ -207,6 +207,21 @@
</select>
</div>
<div class="mb-3">
<label class="form-label" for="language">
<?= lang('language') ?>
<span class="text-danger" hidden>*</span>
</label>
<select id="language" class="form-control required" disabled>
<?php foreach (vars('available_languages') as $available_language): ?>
<option value="<?= $available_language ?>">
<?= ucfirst($available_language) ?>
</option>
<?php endforeach ?>
</select>
</div>
<div class="mb-3">
<label class="form-label" for="timezone">
<?= lang('timezone') ?>

View File

@ -170,6 +170,20 @@
</select>
</div>
<div class="mb-3">
<label class="form-label" for="language">
<?= lang('language') ?>
<span class="text-danger" hidden>*</span>
</label>
<select id="language" class="form-control required" disabled>
<?php foreach (vars('available_languages') as $available_language): ?>
<option value="<?= $available_language ?>">
<?= ucfirst($available_language) ?>
</option>
<?php endforeach ?>
</select>
</div>
<div class="mb-3">
<label class="form-label" for="timezone">
<?= lang('timezone') ?>

View File

@ -26,7 +26,8 @@ App.Pages.Account = (function () {
const $state = $('#state');
const $zipCode = $('#zip-code');
const $notes = $('#notes');
const $timezones = $('#timezone');
const $language = $('#language');
const $timezone = $('#timezone');
const $username = $('#username');
const $password = $('#password');
const $retypePassword = $('#retype-password');
@ -106,7 +107,8 @@ App.Pages.Account = (function () {
$state.val(account.state);
$zipCode.val(account.zip_code);
$notes.val(account.notes);
$timezones.val(account.timezone);
$language.val(account.language);
$timezone.val(account.timezone);
$username.val(account.settings.username);
$password.val('');
$retypePassword.val('');
@ -132,7 +134,8 @@ App.Pages.Account = (function () {
state: $state.val(),
zip_code: $zipCode.val(),
notes: $notes.val(),
timezone: $timezones.val(),
language: $language.val(),
timezone: $timezone.val(),
settings: {
username: $username.val(),
password: $password.val() || null,

View File

@ -27,6 +27,7 @@ App.Pages.Admins = (function () {
const $state = $('#state');
const $zipCode = $('#zip-code');
const $notes = $('#notes');
const $language = $('#language');
const $timezone = $('#timezone');
const $username = $('#username');
const $password = $('#password');
@ -183,6 +184,7 @@ App.Pages.Admins = (function () {
state: $state.val(),
zip_code: $zipCode.val(),
notes: $notes.val(),
language: $language.val(),
timezone: $timezone.val(),
settings: {
username: $username.val(),
@ -334,6 +336,7 @@ App.Pages.Admins = (function () {
$admins.find('.record-details').find('input, select, textarea').val('').prop('disabled', true);
$admins.find('.record-details .form-label span').prop('hidden', true);
$admins.find('.record-details #calendar-view').val('default');
$admins.find('.record-details #language').val('english');
$admins.find('.record-details #timezone').val('UTC');
$('#edit-admin, #delete-admin').prop('disabled', true);
@ -358,6 +361,7 @@ App.Pages.Admins = (function () {
$state.val(admin.state);
$zipCode.val(admin.zip_code);
$notes.val(admin.notes);
$language.val(admin.language);
$timezone.val(admin.timezone);
$username.val(admin.settings.username);

View File

@ -28,6 +28,7 @@ App.Pages.Providers = (function () {
const $zipCode = $('#zip-code');
const $private = $('#private');
const $notes = $('#notes');
const $language = $('#language');
const $timezone = $('#timezone');
const $username = $('#username');
const $password = $('#password');
@ -165,6 +166,7 @@ App.Pages.Providers = (function () {
zip_code: $zipCode.val(),
is_private: Number($private.prop('checked')),
notes: $notes.val(),
language: $language.val(),
timezone: $timezone.val(),
settings: {
username: $username.val(),
@ -345,6 +347,7 @@ App.Pages.Providers = (function () {
$providers.find('.record-details').find('input, select, textarea').val('').prop('disabled', true);
$providers.find('.record-details .form-label span').prop('hidden', true);
$providers.find('.record-details #calendar-view').val('default');
$providers.find('.record-details #language').val('english');
$providers.find('.record-details #timezone').val('UTC');
$providers.find('.add-break, .add-working-plan-exception, #reset-working-plan').prop('disabled', true);
@ -385,6 +388,7 @@ App.Pages.Providers = (function () {
$zipCode.val(provider.zip_code);
$private.prop('checked', provider.is_private);
$notes.val(provider.notes);
$language.val(provider.language);
$timezone.val(provider.timezone);
$username.val(provider.settings.username);

View File

@ -27,6 +27,7 @@ App.Pages.Secretaries = (function () {
const $state = $('#state');
const $zipCode = $('#zip-code');
const $notes = $('#notes');
const $language = $('#language');
const $timezone = $('#timezone');
const $username = $('#username');
const $password = $('#password');
@ -187,6 +188,7 @@ App.Pages.Secretaries = (function () {
state: $state.val(),
zip_code: $zipCode.val(),
notes: $notes.val(),
language: $language.val(),
timezone: $timezone.val(),
settings: {
username: $username.val(),
@ -370,6 +372,7 @@ App.Pages.Secretaries = (function () {
$state.val(secretary.state);
$zipCode.val(secretary.zip_code);
$notes.val(secretary.notes);
$language.val(secretary.language);
$timezone.val(secretary.timezone);
$username.val(secretary.settings.username);