mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Provide initial state
- camelCase language strings Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
3b2be23fee
commit
cc5815dcd0
3 changed files with 17 additions and 16 deletions
|
|
@ -148,6 +148,7 @@ class PersonalInfo implements ISettings {
|
|||
$personalInfoParameters = [
|
||||
'displayNames' => $this->getDisplayNames($account),
|
||||
'emails' => $this->getEmails($account),
|
||||
'languages' => $this->getLanguages($user),
|
||||
];
|
||||
|
||||
$accountParameters = [
|
||||
|
|
@ -256,7 +257,7 @@ class PersonalInfo implements ISettings {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the user language, common language and other languages in an
|
||||
* returns the user's active language, common languages, and other languages in an
|
||||
* associative array
|
||||
*
|
||||
* @param IUser $user
|
||||
|
|
@ -274,12 +275,12 @@ class PersonalInfo implements ISettings {
|
|||
$languages = $this->l10nFactory->getLanguages();
|
||||
|
||||
// associate the user language with the proper array
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code'));
|
||||
$userLang = $languages['commonlanguages'][$userLangIndex];
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
|
||||
$userLang = $languages['commonLanguages'][$userLangIndex];
|
||||
// search in the other languages
|
||||
if ($userLangIndex === false) {
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
|
||||
$userLang = $languages['languages'][$userLangIndex];
|
||||
$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
|
||||
$userLang = $languages['otherLanguages'][$userLangIndex];
|
||||
}
|
||||
// if user language is not available but set somehow: show the actual code as name
|
||||
if (!is_array($userLang)) {
|
||||
|
|
@ -290,7 +291,7 @@ class PersonalInfo implements ISettings {
|
|||
}
|
||||
|
||||
return array_merge(
|
||||
['activelanguage' => $userLang],
|
||||
['activeLanguage' => $userLang],
|
||||
$languages
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,11 +369,11 @@ export default {
|
|||
return [
|
||||
{
|
||||
label: t('settings', 'Common languages'),
|
||||
languages: this.settings.languages.commonlanguages,
|
||||
languages: this.settings.languages.commonLanguages,
|
||||
},
|
||||
{
|
||||
label: t('settings', 'All languages'),
|
||||
languages: this.settings.languages.languages,
|
||||
label: t('settings', 'Other languages'),
|
||||
languages: this.settings.languages.otherLanguages,
|
||||
},
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -619,18 +619,18 @@ class Factory implements IFactory {
|
|||
$potentialName = $l->t('__language_name__');
|
||||
|
||||
return [
|
||||
'commonlanguages' => [[
|
||||
'commonLanguages' => [[
|
||||
'code' => $forceLanguage,
|
||||
'name' => $potentialName,
|
||||
]],
|
||||
'languages' => [],
|
||||
'otherLanguages' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$languageCodes = $this->findAvailableLanguages();
|
||||
|
||||
$commonLanguages = [];
|
||||
$languages = [];
|
||||
$otherLanguages = [];
|
||||
|
||||
foreach ($languageCodes as $lang) {
|
||||
$l = $this->get('lib', $lang);
|
||||
|
|
@ -658,14 +658,14 @@ class Factory implements IFactory {
|
|||
if (in_array($lang, self::COMMON_LANGUAGE_CODES)) {
|
||||
$commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln;
|
||||
} else {
|
||||
$languages[] = $ln;
|
||||
$otherLanguages[] = $ln;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($commonLanguages);
|
||||
|
||||
// sort now by displayed language not the iso-code
|
||||
usort($languages, function ($a, $b) {
|
||||
usort($otherLanguages, function ($a, $b) {
|
||||
if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
|
||||
// If a doesn't have a name, but b does, list b before a
|
||||
return 1;
|
||||
|
|
@ -680,8 +680,8 @@ class Factory implements IFactory {
|
|||
|
||||
return [
|
||||
// reset indexes
|
||||
'commonlanguages' => array_values($commonLanguages),
|
||||
'languages' => $languages
|
||||
'commonLanguages' => array_values($commonLanguages),
|
||||
'otherLanguages' => $otherLanguages
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue