Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public function testAddUserAlreadyExisting() {
->method('isAdmin')
->with('adminUser')
->willReturn(true);
$l10n = $this->createMock(IL10N::class);
$this->l10nFactory
->expects($this->once())
->method('get')
->with('provisioning_api')
->willReturn($l10n);

$this->api->addUser('AlreadyExistingUser', 'password', '', '', []);
}
Expand Down
7 changes: 1 addition & 6 deletions apps/settings/css/settings.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/settings/css/settings.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions apps/settings/css/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ input {
display: inline-grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr 1fr 2fr;

#locale {
h3 {
height: 44px;
display: flex;
align-items: center;
}
}
}

.personal-show-container {
Expand All @@ -78,9 +70,7 @@ input {
}

select {
&#timezone,
&#languageinput,
&#localeinput {
&#timezone {
width: 100%;
}
}
Expand Down
58 changes: 0 additions & 58 deletions apps/settings/js/settings/personalInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,62 +108,4 @@ window.addEventListener('DOMContentLoaded', function () {
});

federationSettingsView.render();

var updateLanguage = function () {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(updateLanguage);
return;
}

var selectedLang = $("#languageinput").val(),
user = OC.getCurrentUser();

$.ajax({
url: OC.linkToOCS('cloud/users', 2) + user['uid'],
method: 'PUT',
data: {
key: 'language',
value: selectedLang
},
success: function() {
location.reload();
},
fail: function() {
OC.Notification.showTemporary(t('settings', 'An error occurred while changing your language. Please reload the page and try again.'));
}
});
};
$("#languageinput").change(updateLanguage);

var updateLocale = function () {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(updateLocale);
return;
}

var selectedLocale = $("#localeinput").val(),
user = OC.getCurrentUser();

$.ajax({
url: OC.linkToOCS('cloud/users', 2) + user.uid,
method: 'PUT',
data: {
key: 'locale',
value: selectedLocale
},
success: function() {
moment.locale(selectedLocale);
},
fail: function() {
OC.Notification.showTemporary(t('settings', 'An error occurred while changing your locale. Please reload the page and try again.'));
}
});
};
$("#localeinput").change(updateLocale);
});

window.setInterval(function() {
$('#localeexample-time').text(moment().format('LTS'))
$('#localeexample-date').text(moment().format('L'))
$('#localeexample-fdow').text(t('settings', 'Week starts on {fdow}', { fdow: dayNames[firstDay] }))
}, 1000)
25 changes: 9 additions & 16 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ public function getForm(): TemplateResponse {
$totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
}

$localeParameters = $this->getLocales($user);
$messageParameters = $this->getMessageParameters($account);

$parameters = [
'federationEnabled' => $federationEnabled,
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
] + $messageParameters + $localeParameters;
] + $messageParameters;

$personalInfoParameters = [
'userId' => $uid,
Expand All @@ -160,6 +159,7 @@ public function getForm(): TemplateResponse {
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
'languageMap' => $this->getLanguageMap($user),
'localeMap' => $this->getLocaleMap($user),
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
'profileEnabled' => $this->profileManager->isProfileEnabled($user),
'organisation' => $this->getProperty($account, IAccountManager::PROPERTY_ORGANISATION),
Expand Down Expand Up @@ -315,31 +315,24 @@ private function getLanguageMap(IUser $user): array {
);
}

private function getLocales(IUser $user): array {
private function getLocaleMap(IUser $user): array {
$forceLanguage = $this->config->getSystemValue('force_locale', false);
if ($forceLanguage !== false) {
return [];
}

$uid = $user->getUID();

$userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale());

$userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());

$localeCodes = $this->l10nFactory->findAvailableLocales();

$userLocale = array_filter($localeCodes, function ($value) use ($userLocaleString) {
return $userLocaleString === $value['code'];
});
$userLocale = array_filter($localeCodes, fn ($value) => $userLocaleString === $value['code']);

if (!empty($userLocale)) {
$userLocale = reset($userLocale);
}

$localesForLanguage = array_filter($localeCodes, function ($localeCode) use ($userLang) {
return 0 === strpos($localeCode['code'], $userLang);
});
$localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) === 0));
$otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) !== 0));

if (!$userLocale) {
$userLocale = [
Expand All @@ -349,10 +342,10 @@ private function getLocales(IUser $user): array {
}

return [
'activelocaleLang' => $userLocaleString,
'activelocale' => $userLocale,
'locales' => $localeCodes,
'activeLocaleLang' => $userLocaleString,
'activeLocale' => $userLocale,
'localesForLanguage' => $localesForLanguage,
'otherLocales' => $otherLocales,
];
}

Expand Down
Loading