Allow user to choose locale

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
pull/5623/head
Thomas Citharel 7 years ago committed by Georg Ehrke
parent 221f558f66
commit d8921ccd85
No known key found for this signature in database
GPG Key ID: 9D98FD9380A1CB43
  1. 20
      apps/provisioning_api/lib/Controller/UsersController.php
  2. 48
      lib/private/Settings/Personal/PersonalInfo.php
  3. 436
      lib/private/Settings/Personal/locales.json
  4. 27
      settings/js/settings/personalInfo.js
  5. 27
      settings/templates/settings/personal/personal.info.php

@ -13,6 +13,7 @@ declare(strict_types=1);
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tom Needham <tom@owncloud.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Thomas Citharel <tcit@tcit.fr>
*
* @license AGPL-3.0
*
@ -391,6 +392,19 @@ class UsersController extends AUserData {
}
}
// Find the data
$data['id'] = $targetUserObject->getUID();
$data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
$data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
$data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
$data[AccountManager::PROPERTY_PHONE] = $userAccount[AccountManager::PROPERTY_PHONE]['value'];
$data[AccountManager::PROPERTY_ADDRESS] = $userAccount[AccountManager::PROPERTY_ADDRESS]['value'];
$data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids;
$data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang');
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
return new DataResponse($permittedFields);
}
@ -428,6 +442,7 @@ class UsersController extends AUserData {
if ($this->config->getSystemValue('force_language', false) === false ||
$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
$permittedFields[] = 'language';
$permittedFields[] = 'locale';
}
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
@ -456,6 +471,7 @@ class UsersController extends AUserData {
$permittedFields[] = AccountManager::PROPERTY_EMAIL;
$permittedFields[] = 'password';
$permittedFields[] = 'language';
$permittedFields[] = 'locale';
$permittedFields[] = AccountManager::PROPERTY_PHONE;
$permittedFields[] = AccountManager::PROPERTY_ADDRESS;
$permittedFields[] = AccountManager::PROPERTY_WEBSITE;
@ -505,6 +521,10 @@ class UsersController extends AUserData {
}
$this->config->setUserValue($targetUser->getUID(), 'core', 'lang', $value);
break;
case 'locale':
// do some stuff
$this->config->setUserValue($targetUser->getUID(), 'core', 'locale', $value);
break;
case AccountManager::PROPERTY_EMAIL:
if (filter_var($value, FILTER_VALIDATE_EMAIL) || $value === '') {
$targetUser->setEMailAddress($value);

@ -4,6 +4,7 @@
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Citharel <tcit@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
@ -106,6 +107,7 @@ class PersonalInfo implements ISettings {
}
$languageParameters = $this->getLanguages($user);
$localeParameters = $this->getLocales($user);
$messageParameters = $this->getMessageParameters($userData);
$parameters = [
@ -134,7 +136,7 @@ class PersonalInfo implements ISettings {
'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
'groups' => $this->getGroups($user),
'passwordChangeSupported' => $user->canChangePassword(),
] + $messageParameters + $languageParameters;
] + $messageParameters + $languageParameters + $localeParameters;
return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
@ -218,6 +220,50 @@ class PersonalInfo implements ISettings {
);
}
private function getLocales(IUser $user) {
$forceLanguage = $this->config->getSystemValue('force_locale', false);
if($forceLanguage !== false) {
return [];
}
$uid = $user->getUID();
$userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', 'en_US');
$userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
$localeData = file_get_contents(__DIR__ . '/locales.json');
$localeCodes = json_decode($localeData, true);
$userLocale = array_filter($localeCodes, function($value) use ($userLocaleString) {
return $userLocaleString === $value['code'];
});
if (count($userLocale) > 0)
{
$userLocale = reset($userLocale);
}
$localesForLanguage = array_filter($localeCodes, function($localeCode) use ($userLang) {
return 0 === strpos($localeCode['code'], $userLang);
});
/*$localesForLanguage = [];
foreach (array_keys($localeCodes) as $localeCode) {
if (0 === strpos($localeCode, $userLang)) {
$localesForLanguage[] = $localeCode;
}
}*/
return [
'activelocaleLang' => $userLocaleString,
'activelocale' => $userLocale,
'locales' => $localeCodes,
'localesforlanguage' => $localesForLanguage,
];
}
/**
* @param array $userData
* @return array

@ -0,0 +1,436 @@
[
{ "code":"af_NA", "name":"Afrikaans (Namibia)"},
{ "code":"af_ZA", "name":"Afrikaans (South Africa)"},
{ "code":"af", "name":"Afrikaans"},
{ "code":"ak_GH", "name":"Akan (Ghana)"},
{ "code":"ak", "name":"Akan"},
{ "code":"sq_AL", "name":"Albanian (Albania)"},
{ "code":"sq", "name":"Albanian"},
{ "code":"am_ET", "name":"Amharic (Ethiopia)"},
{ "code":"am", "name":"Amharic"},
{ "code":"ar_DZ", "name":"Arabic (Algeria)"},
{ "code":"ar_BH", "name":"Arabic (Bahrain)"},
{ "code":"ar_EG", "name":"Arabic (Egypt)"},
{ "code":"ar_IQ", "name":"Arabic (Iraq)"},
{ "code":"ar_JO", "name":"Arabic (Jordan)"},
{ "code":"ar_KW", "name":"Arabic (Kuwait)"},
{ "code":"ar_LB", "name":"Arabic (Lebanon)"},
{ "code":"ar_LY", "name":"Arabic (Libya)"},
{ "code":"ar_MA", "name":"Arabic (Morocco)"},
{ "code":"ar_OM", "name":"Arabic (Oman)"},
{ "code":"ar_QA", "name":"Arabic (Qatar)"},
{ "code":"ar_SA", "name":"Arabic (Saudi Arabia)"},
{ "code":"ar_SD", "name":"Arabic (Sudan)"},
{ "code":"ar_SY", "name":"Arabic (Syria)"},
{ "code":"ar_TN", "name":"Arabic (Tunisia)"},
{ "code":"ar_AE", "name":"Arabic (United Arab Emirates)"},
{ "code":"ar_YE", "name":"Arabic (Yemen)"},
{ "code":"ar", "name":"Arabic"},
{ "code":"hy_AM", "name":"Armenian (Armenia)"},
{ "code":"hy", "name":"Armenian"},
{ "code":"as_IN", "name":"Assamese (India)"},
{ "code":"as", "name":"Assamese"},
{ "code":"asa_TZ", "name":"Asu (Tanzania)"},
{ "code":"asa", "name":"Asu"},
{ "code":"az_Cyrl", "name":"Azerbaijani (Cyrillic)"},
{ "code":"az_Cyrl_AZ", "name":"Azerbaijani (Cyrillic, Azerbaijan)"},
{ "code":"az_Latn", "name":"Azerbaijani (Latin)"},
{ "code":"az_Latn_AZ", "name":"Azerbaijani (Latin, Azerbaijan)"},
{ "code":"az", "name":"Azerbaijani"},
{ "code":"bm_ML", "name":"Bambara (Mali)"},
{ "code":"bm", "name":"Bambara"},
{ "code":"eu_ES", "name":"Basque (Spain)"},
{ "code":"eu", "name":"Basque"},
{ "code":"be_BY", "name":"Belarusian (Belarus)"},
{ "code":"be", "name":"Belarusian"},
{ "code":"bem_ZM", "name":"Bemba (Zambia)"},
{ "code":"bem", "name":"Bemba"},
{ "code":"bez_TZ", "name":"Bena (Tanzania)"},
{ "code":"bez", "name":"Bena"},
{ "code":"bn_BD", "name":"Bengali (Bangladesh)"},
{ "code":"bn_IN", "name":"Bengali (India)"},
{ "code":"bn", "name":"Bengali"},
{ "code":"bs_BA", "name":"Bosnian (Bosnia and Herzegovina)"},
{ "code":"bs", "name":"Bosnian"},
{ "code":"bg_BG", "name":"Bulgarian (Bulgaria)"},
{ "code":"bg", "name":"Bulgarian"},
{ "code":"my_MM", "name":"Burmese (Myanmar [Burma])"},
{ "code":"my", "name":"Burmese"},
{ "code":"ca_ES", "name":"Catalan (Spain)"},
{ "code":"ca", "name":"Catalan"},
{ "code":"tzm_Latn", "name":"Central Morocco Tamazight (Latin)"},
{ "code":"tzm_Latn_MA", "name":"Central Morocco Tamazight (Latin, Morocco)"},
{ "code":"tzm", "name":"Central Morocco Tamazight"},
{ "code":"chr_US", "name":"Cherokee (United States)"},
{ "code":"chr", "name":"Cherokee"},
{ "code":"cgg_UG", "name":"Chiga (Uganda)"},
{ "code":"cgg", "name":"Chiga"},
{ "code":"zh_Hans", "name":"Chinese (Simplified Han)"},
{ "code":"zh_Hans_CN", "name":"Chinese (Simplified Han, China)"},
{ "code":"zh_Hans_HK", "name":"Chinese (Simplified Han, Hong Kong SAR China)"},
{ "code":"zh_Hans_MO", "name":"Chinese (Simplified Han, Macau SAR China)"},
{ "code":"zh_Hans_SG", "name":"Chinese (Simplified Han, Singapore)"},
{ "code":"zh_Hant", "name":"Chinese (Traditional Han)"},
{ "code":"zh_Hant_HK", "name":"Chinese (Traditional Han, Hong Kong SAR China)"},
{ "code":"zh_Hant_MO", "name":"Chinese (Traditional Han, Macau SAR China)"},
{ "code":"zh_Hant_TW", "name":"Chinese (Traditional Han, Taiwan)"},
{ "code":"zh", "name":"Chinese"},
{ "code":"kw_GB", "name":"Cornish (United Kingdom)"},
{ "code":"kw", "name":"Cornish"},
{ "code":"hr_HR", "name":"Croatian (Croatia)"},
{ "code":"hr", "name":"Croatian"},
{ "code":"cs_CZ", "name":"Czech (Czech Republic)"},
{ "code":"cs", "name":"Czech"},
{ "code":"da_DK", "name":"Danish (Denmark)"},
{ "code":"da", "name":"Danish"},
{ "code":"nl_BE", "name":"Dutch (Belgium)"},
{ "code":"nl_NL", "name":"Dutch (Netherlands)"},
{ "code":"nl", "name":"Dutch"},
{ "code":"ebu_KE", "name":"Embu (Kenya)"},
{ "code":"ebu", "name":"Embu"},
{ "code":"en_AS", "name":"English (American Samoa)"},
{ "code":"en_AU", "name":"English (Australia)"},
{ "code":"en_BE", "name":"English (Belgium)"},
{ "code":"en_BZ", "name":"English (Belize)"},
{ "code":"en_BW", "name":"English (Botswana)"},
{ "code":"en_CA", "name":"English (Canada)"},
{ "code":"en_GU", "name":"English (Guam)"},
{ "code":"en_HK", "name":"English (Hong Kong SAR China)"},
{ "code":"en_IN", "name":"English (India)"},
{ "code":"en_IE", "name":"English (Ireland)"},
{ "code":"en_JM", "name":"English (Jamaica)"},
{ "code":"en_MT", "name":"English (Malta)"},
{ "code":"en_MH", "name":"English (Marshall Islands)"},
{ "code":"en_MU", "name":"English (Mauritius)"},
{ "code":"en_NA", "name":"English (Namibia)"},
{ "code":"en_NZ", "name":"English (New Zealand)"},
{ "code":"en_MP", "name":"English (Northern Mariana Islands)"},
{ "code":"en_PK", "name":"English (Pakistan)"},
{ "code":"en_PH", "name":"English (Philippines)"},
{ "code":"en_SG", "name":"English (Singapore)"},
{ "code":"en_ZA", "name":"English (South Africa)"},
{ "code":"en_TT", "name":"English (Trinidad and Tobago)"},
{ "code":"en_UM", "name":"English (U.S. Minor Outlying Islands)"},
{ "code":"en_VI", "name":"English (U.S. Virgin Islands)"},
{ "code":"en_GB", "name":"English (United Kingdom)"},
{ "code":"en_US", "name":"English (United States)"},
{ "code":"en_ZW", "name":"English (Zimbabwe)"},
{ "code":"en", "name":"English"},
{ "code":"eo", "name":"Esperanto"},
{ "code":"et_EE", "name":"Estonian (Estonia)"},
{ "code":"et", "name":"Estonian"},
{ "code":"ee_GH", "name":"Ewe (Ghana)"},
{ "code":"ee_TG", "name":"Ewe (Togo)"},
{ "code":"ee", "name":"Ewe"},
{ "code":"fo_FO", "name":"Faroese (Faroe Islands)"},
{ "code":"fo", "name":"Faroese"},
{ "code":"fil_PH", "name":"Filipino (Philippines)"},
{ "code":"fil", "name":"Filipino"},
{ "code":"fi_FI", "name":"Finnish (Finland)"},
{ "code":"fi", "name":"Finnish"},
{ "code":"fr_BE", "name":"French (Belgium)"},
{ "code":"fr_BJ", "name":"French (Benin)"},
{ "code":"fr_BF", "name":"French (Burkina Faso)"},
{ "code":"fr_BI", "name":"French (Burundi)"},
{ "code":"fr_CM", "name":"French (Cameroon)"},
{ "code":"fr_CA", "name":"French (Canada)"},
{ "code":"fr_CF", "name":"French (Central African Republic)"},
{ "code":"fr_TD", "name":"French (Chad)"},
{ "code":"fr_KM", "name":"French (Comoros)"},
{ "code":"fr_CG", "name":"French (Congo - Brazzaville)"},
{ "code":"fr_CD", "name":"French (Congo - Kinshasa)"},
{ "code":"fr_CI", "name":"French (Côte d’Ivoire)"},
{ "code":"fr_DJ", "name":"French (Djibouti)"},
{ "code":"fr_GQ", "name":"French (Equatorial Guinea)"},
{ "code":"fr_FR", "name":"French (France)"},
{ "code":"fr_GA", "name":"French (Gabon)"},
{ "code":"fr_GP", "name":"French (Guadeloupe)"},
{ "code":"fr_GN", "name":"French (Guinea)"},
{ "code":"fr_LU", "name":"French (Luxembourg)"},
{ "code":"fr_MG", "name":"French (Madagascar)"},
{ "code":"fr_ML", "name":"French (Mali)"},
{ "code":"fr_MQ", "name":"French (Martinique)"},
{ "code":"fr_MC", "name":"French (Monaco)"},
{ "code":"fr_NE", "name":"French (Niger)"},
{ "code":"fr_RW", "name":"French (Rwanda)"},
{ "code":"fr_RE", "name":"French (Réunion)"},
{ "code":"fr_BL", "name":"French (Saint Barthélemy)"},
{ "code":"fr_MF", "name":"French (Saint Martin)"},
{ "code":"fr_SN", "name":"French (Senegal)"},
{ "code":"fr_CH", "name":"French (Switzerland)"},
{ "code":"fr_TG", "name":"French (Togo)"},
{ "code":"fr", "name":"French"},
{ "code":"ff_SN", "name":"Fulah (Senegal)"},
{ "code":"ff", "name":"Fulah"},
{ "code":"gl_ES", "name":"Galician (Spain)"},
{ "code":"gl", "name":"Galician"},
{ "code":"lg_UG", "name":"Ganda (Uganda)"},
{ "code":"lg", "name":"Ganda"},
{ "code":"ka_GE", "name":"Georgian (Georgia)"},
{ "code":"ka", "name":"Georgian"},
{ "code":"de_AT", "name":"German (Austria)"},
{ "code":"de_BE", "name":"German (Belgium)"},
{ "code":"de_DE", "name":"German (Germany)"},
{ "code":"de_LI", "name":"German (Liechtenstein)"},
{ "code":"de_LU", "name":"German (Luxembourg)"},
{ "code":"de_CH", "name":"German (Switzerland)"},
{ "code":"de", "name":"German"},
{ "code":"el_CY", "name":"Greek (Cyprus)"},
{ "code":"el_GR", "name":"Greek (Greece)"},
{ "code":"el", "name":"Greek"},
{ "code":"gu_IN", "name":"Gujarati (India)"},
{ "code":"gu", "name":"Gujarati"},
{ "code":"guz_KE", "name":"Gusii (Kenya)"},
{ "code":"guz", "name":"Gusii"},
{ "code":"ha_Latn", "name":"Hausa (Latin)"},
{ "code":"ha_Latn_GH", "name":"Hausa (Latin, Ghana)"},
{ "code":"ha_Latn_NE", "name":"Hausa (Latin, Niger)"},
{ "code":"ha_Latn_NG", "name":"Hausa (Latin, Nigeria)"},
{ "code":"ha", "name":"Hausa"},
{ "code":"haw_US", "name":"Hawaiian (United States)"},
{ "code":"haw", "name":"Hawaiian"},
{ "code":"he_IL", "name":"Hebrew (Israel)"},
{ "code":"he", "name":"Hebrew"},
{ "code":"hi_IN", "name":"Hindi (India)"},
{ "code":"hi", "name":"Hindi"},
{ "code":"hu_HU", "name":"Hungarian (Hungary)"},
{ "code":"hu", "name":"Hungarian"},
{ "code":"is_IS", "name":"Icelandic (Iceland)"},
{ "code":"is", "name":"Icelandic"},
{ "code":"ig_NG", "name":"Igbo (Nigeria)"},
{ "code":"ig", "name":"Igbo"},
{ "code":"id_ID", "name":"Indonesian (Indonesia)"},
{ "code":"id", "name":"Indonesian"},
{ "code":"ga_IE", "name":"Irish (Ireland)"},
{ "code":"ga", "name":"Irish"},
{ "code":"it_IT", "name":"Italian (Italy)"},
{ "code":"it_CH", "name":"Italian (Switzerland)"},
{ "code":"it", "name":"Italian"},
{ "code":"ja_JP", "name":"Japanese (Japan)"},
{ "code":"ja", "name":"Japanese"},
{ "code":"kea_CV", "name":"Kabuverdianu (Cape Verde)"},
{ "code":"kea", "name":"Kabuverdianu"},
{ "code":"kab_DZ", "name":"Kabyle (Algeria)"},
{ "code":"kab", "name":"Kabyle"},
{ "code":"kl_GL", "name":"Kalaallisut (Greenland)"},
{ "code":"kl", "name":"Kalaallisut"},
{ "code":"kln_KE", "name":"Kalenjin (Kenya)"},
{ "code":"kln", "name":"Kalenjin"},
{ "code":"kam_KE", "name":"Kamba (Kenya)"},
{ "code":"kam", "name":"Kamba"},
{ "code":"kn_IN", "name":"Kannada (India)"},
{ "code":"kn", "name":"Kannada"},
{ "code":"kk_Cyrl", "name":"Kazakh (Cyrillic)"},
{ "code":"kk_Cyrl_KZ", "name":"Kazakh (Cyrillic, Kazakhstan)"},
{ "code":"kk", "name":"Kazakh"},
{ "code":"km_KH", "name":"Khmer (Cambodia)"},
{ "code":"km", "name":"Khmer"},
{ "code":"ki_KE", "name":"Kikuyu (Kenya)"},
{ "code":"ki", "name":"Kikuyu"},
{ "code":"rw_RW", "name":"Kinyarwanda (Rwanda)"},
{ "code":"rw", "name":"Kinyarwanda"},
{ "code":"kok_IN", "name":"Konkani (India)"},
{ "code":"kok", "name":"Konkani"},
{ "code":"ko_KR", "name":"Korean (South Korea)"},
{ "code":"ko", "name":"Korean"},
{ "code":"khq_ML", "name":"Koyra Chiini (Mali)"},
{ "code":"khq", "name":"Koyra Chiini"},
{ "code":"ses_ML", "name":"Koyraboro Senni (Mali)"},
{ "code":"ses", "name":"Koyraboro Senni"},
{ "code":"lag_TZ", "name":"Langi (Tanzania)"},
{ "code":"lag", "name":"Langi"},
{ "code":"lv_LV", "name":"Latvian (Latvia)"},
{ "code":"lv", "name":"Latvian"},
{ "code":"lt_LT", "name":"Lithuanian (Lithuania)"},
{ "code":"lt", "name":"Lithuanian"},
{ "code":"luo_KE", "name":"Luo (Kenya)"},
{ "code":"luo", "name":"Luo"},
{ "code":"luy_KE", "name":"Luyia (Kenya)"},
{ "code":"luy", "name":"Luyia"},
{ "code":"mk_MK", "name":"Macedonian (Macedonia)"},
{ "code":"mk", "name":"Macedonian"},
{ "code":"jmc_TZ", "name":"Machame (Tanzania)"},
{ "code":"jmc", "name":"Machame"},
{ "code":"kde_TZ", "name":"Makonde (Tanzania)"},
{ "code":"kde", "name":"Makonde"},
{ "code":"mg_MG", "name":"Malagasy (Madagascar)"},
{ "code":"mg", "name":"Malagasy"},
{ "code":"ms_BN", "name":"Malay (Brunei)"},
{ "code":"ms_MY", "name":"Malay (Malaysia)"},
{ "code":"ms", "name":"Malay"},
{ "code":"ml_IN", "name":"Malayalam (India)"},
{ "code":"ml", "name":"Malayalam"},
{ "code":"mt_MT", "name":"Maltese (Malta)"},
{ "code":"mt", "name":"Maltese"},
{ "code":"gv_GB", "name":"Manx (United Kingdom)"},
{ "code":"gv", "name":"Manx"},
{ "code":"mr_IN", "name":"Marathi (India)"},
{ "code":"mr", "name":"Marathi"},
{ "code":"mas_KE", "name":"Masai (Kenya)"},
{ "code":"mas_TZ", "name":"Masai (Tanzania)"},
{ "code":"mas", "name":"Masai"},
{ "code":"mer_KE", "name":"Meru (Kenya)"},
{ "code":"mer", "name":"Meru"},
{ "code":"mfe_MU", "name":"Morisyen (Mauritius)"},
{ "code":"mfe", "name":"Morisyen"},
{ "code":"naq_NA", "name":"Nama (Namibia)"},
{ "code":"naq", "name":"Nama"},
{ "code":"ne_IN", "name":"Nepali (India)"},
{ "code":"ne_NP", "name":"Nepali (Nepal)"},
{ "code":"ne", "name":"Nepali"},
{ "code":"nd_ZW", "name":"North Ndebele (Zimbabwe)"},
{ "code":"nd", "name":"North Ndebele"},
{ "code":"nb_NO", "name":"Norwegian Bokmål (Norway)"},
{ "code":"nb", "name":"Norwegian Bokmål"},
{ "code":"nn_NO", "name":"Norwegian Nynorsk (Norway)"},
{ "code":"nn", "name":"Norwegian Nynorsk"},
{ "code":"nyn_UG", "name":"Nyankole (Uganda)"},
{ "code":"nyn", "name":"Nyankole"},
{ "code":"or_IN", "name":"Oriya (India)"},
{ "code":"or", "name":"Oriya"},
{ "code":"om_ET", "name":"Oromo (Ethiopia)"},
{ "code":"om_KE", "name":"Oromo (Kenya)"},
{ "code":"om", "name":"Oromo"},
{ "code":"ps_AF", "name":"Pashto (Afghanistan)"},
{ "code":"ps", "name":"Pashto"},
{ "code":"fa_AF", "name":"Persian (Afghanistan)"},
{ "code":"fa_IR", "name":"Persian (Iran)"},
{ "code":"fa", "name":"Persian"},
{ "code":"pl_PL", "name":"Polish (Poland)"},
{ "code":"pl", "name":"Polish"},
{ "code":"pt_BR", "name":"Portuguese (Brazil)"},
{ "code":"pt_GW", "name":"Portuguese (Guinea-Bissau)"},
{ "code":"pt_MZ", "name":"Portuguese (Mozambique)"},
{ "code":"pt_PT", "name":"Portuguese (Portugal)"},
{ "code":"pt", "name":"Portuguese"},
{ "code":"pa_Arab", "name":"Punjabi (Arabic)"},
{ "code":"pa_Arab_PK", "name":"Punjabi (Arabic, Pakistan)"},
{ "code":"pa_Guru", "name":"Punjabi (Gurmukhi)"},
{ "code":"pa_Guru_IN", "name":"Punjabi (Gurmukhi, India)"},
{ "code":"pa", "name":"Punjabi"},
{ "code":"ro_MD", "name":"Romanian (Moldova)"},
{ "code":"ro_RO", "name":"Romanian (Romania)"},
{ "code":"ro", "name":"Romanian"},
{ "code":"rm_CH", "name":"Romansh (Switzerland)"},
{ "code":"rm", "name":"Romansh"},
{ "code":"rof_TZ", "name":"Rombo (Tanzania)"},
{ "code":"rof", "name":"Rombo"},
{ "code":"ru_MD", "name":"Russian (Moldova)"},
{ "code":"ru_RU", "name":"Russian (Russia)"},
{ "code":"ru_UA", "name":"Russian (Ukraine)"},
{ "code":"ru", "name":"Russian"},
{ "code":"rwk_TZ", "name":"Rwa (Tanzania)"},
{ "code":"rwk", "name":"Rwa"},
{ "code":"saq_KE", "name":"Samburu (Kenya)"},
{ "code":"saq", "name":"Samburu"},
{ "code":"sg_CF", "name":"Sango (Central African Republic)"},
{ "code":"sg", "name":"Sango"},
{ "code":"seh_MZ", "name":"Sena (Mozambique)"},
{ "code":"seh", "name":"Sena"},
{ "code":"sr_Cyrl", "name":"Serbian (Cyrillic)"},
{ "code":"sr_Cyrl_BA", "name":"Serbian (Cyrillic, Bosnia and Herzegovina)"},
{ "code":"sr_Cyrl_ME", "name":"Serbian (Cyrillic, Montenegro)"},
{ "code":"sr_Cyrl_RS", "name":"Serbian (Cyrillic, Serbia)"},
{ "code":"sr_Latn", "name":"Serbian (Latin)"},
{ "code":"sr_Latn_BA", "name":"Serbian (Latin, Bosnia and Herzegovina)"},
{ "code":"sr_Latn_ME", "name":"Serbian (Latin, Montenegro)"},
{ "code":"sr_Latn_RS", "name":"Serbian (Latin, Serbia)"},
{ "code":"sr", "name":"Serbian"},
{ "code":"sn_ZW", "name":"Shona (Zimbabwe)"},
{ "code":"sn", "name":"Shona"},
{ "code":"ii_CN", "name":"Sichuan Yi (China)"},
{ "code":"ii", "name":"Sichuan Yi"},
{ "code":"si_LK", "name":"Sinhala (Sri Lanka)"},
{ "code":"si", "name":"Sinhala"},
{ "code":"sk_SK", "name":"Slovak (Slovakia)"},
{ "code":"sk", "name":"Slovak"},
{ "code":"sl_SI", "name":"Slovenian (Slovenia)"},
{ "code":"sl", "name":"Slovenian"},
{ "code":"xog_UG", "name":"Soga (Uganda)"},
{ "code":"xog", "name":"Soga"},
{ "code":"so_DJ", "name":"Somali (Djibouti)"},
{ "code":"so_ET", "name":"Somali (Ethiopia)"},
{ "code":"so_KE", "name":"Somali (Kenya)"},
{ "code":"so_SO", "name":"Somali (Somalia)"},
{ "code":"so", "name":"Somali"},
{ "code":"es_AR", "name":"Spanish (Argentina)"},
{ "code":"es_BO", "name":"Spanish (Bolivia)"},
{ "code":"es_CL", "name":"Spanish (Chile)"},
{ "code":"es_CO", "name":"Spanish (Colombia)"},
{ "code":"es_CR", "name":"Spanish (Costa Rica)"},
{ "code":"es_DO", "name":"Spanish (Dominican Republic)"},
{ "code":"es_EC", "name":"Spanish (Ecuador)"},
{ "code":"es_SV", "name":"Spanish (El Salvador)"},
{ "code":"es_GQ", "name":"Spanish (Equatorial Guinea)"},
{ "code":"es_GT", "name":"Spanish (Guatemala)"},
{ "code":"es_HN", "name":"Spanish (Honduras)"},
{ "code":"es_419", "name":"Spanish (Latin America)"},
{ "code":"es_MX", "name":"Spanish (Mexico)"},
{ "code":"es_NI", "name":"Spanish (Nicaragua)"},
{ "code":"es_PA", "name":"Spanish (Panama)"},
{ "code":"es_PY", "name":"Spanish (Paraguay)"},
{ "code":"es_PE", "name":"Spanish (Peru)"},
{ "code":"es_PR", "name":"Spanish (Puerto Rico)"},
{ "code":"es_ES", "name":"Spanish (Spain)"},
{ "code":"es_US", "name":"Spanish (United States)"},
{ "code":"es_UY", "name":"Spanish (Uruguay)"},
{ "code":"es_VE", "name":"Spanish (Venezuela)"},
{ "code":"es", "name":"Spanish"},
{ "code":"sw_KE", "name":"Swahili (Kenya)"},
{ "code":"sw_TZ", "name":"Swahili (Tanzania)"},
{ "code":"sw", "name":"Swahili"},
{ "code":"sv_FI", "name":"Swedish (Finland)"},
{ "code":"sv_SE", "name":"Swedish (Sweden)"},
{ "code":"sv", "name":"Swedish"},
{ "code":"gsw_CH", "name":"Swiss German (Switzerland)"},
{ "code":"gsw", "name":"Swiss German"},
{ "code":"shi_Latn", "name":"Tachelhit (Latin)"},
{ "code":"shi_Latn_MA", "name":"Tachelhit (Latin, Morocco)"},
{ "code":"shi_Tfng", "name":"Tachelhit (Tifinagh)"},
{ "code":"shi_Tfng_MA", "name":"Tachelhit (Tifinagh, Morocco)"},
{ "code":"shi", "name":"Tachelhit"},
{ "code":"dav_KE", "name":"Taita (Kenya)"},
{ "code":"dav", "name":"Taita"},
{ "code":"ta_IN", "name":"Tamil (India)"},
{ "code":"ta_LK", "name":"Tamil (Sri Lanka)"},
{ "code":"ta", "name":"Tamil"},
{ "code":"te_IN", "name":"Telugu (India)"},
{ "code":"te", "name":"Telugu"},
{ "code":"teo_KE", "name":"Teso (Kenya)"},
{ "code":"teo_UG", "name":"Teso (Uganda)"},
{ "code":"teo", "name":"Teso"},
{ "code":"th_TH", "name":"Thai (Thailand)"},
{ "code":"th", "name":"Thai"},
{ "code":"bo_CN", "name":"Tibetan (China)"},
{ "code":"bo_IN", "name":"Tibetan (India)"},
{ "code":"bo", "name":"Tibetan"},
{ "code":"ti_ER", "name":"Tigrinya (Eritrea)"},
{ "code":"ti_ET", "name":"Tigrinya (Ethiopia)"},
{ "code":"ti", "name":"Tigrinya"},
{ "code":"to_TO", "name":"Tonga (Tonga)"},
{ "code":"to", "name":"Tonga"},
{ "code":"tr_TR", "name":"Turkish (Turkey)"},
{ "code":"tr", "name":"Turkish"},
{ "code":"uk_UA", "name":"Ukrainian (Ukraine)"},
{ "code":"uk", "name":"Ukrainian"},
{ "code":"ur_IN", "name":"Urdu (India)"},
{ "code":"ur_PK", "name":"Urdu (Pakistan)"},
{ "code":"ur", "name":"Urdu"},
{ "code":"uz_Arab", "name":"Uzbek (Arabic)"},
{ "code":"uz_Arab_AF", "name":"Uzbek (Arabic, Afghanistan)"},
{ "code":"uz_Cyrl", "name":"Uzbek (Cyrillic)"},
{ "code":"uz_Cyrl_UZ", "name":"Uzbek (Cyrillic, Uzbekistan)"},
{ "code":"uz_Latn", "name":"Uzbek (Latin)"},
{ "code":"uz_Latn_UZ", "name":"Uzbek (Latin, Uzbekistan)"},
{ "code":"uz", "name":"Uzbek"},
{ "code":"vi_VN", "name":"Vietnamese (Vietnam)"},
{ "code":"vi", "name":"Vietnamese"},
{ "code":"vun_TZ", "name":"Vunjo (Tanzania)"},
{ "code":"vun", "name":"Vunjo"},
{ "code":"cy_GB", "name":"Welsh (United Kingdom)"},
{ "code":"cy", "name":"Welsh"},
{ "code":"yo_NG", "name":"Yoruba (Nigeria)"},
{ "code":"yo", "name":"Yoruba"},
{ "code":"zu_ZA", "name":"Zulu (South Africa)"},
{ "code":"zu", "name":"Zulu"}
]

@ -5,6 +5,7 @@
* 2013, Morris Jobke <morris.jobke@gmail.com>
* 2016, Christoph Wurst <christoph@owncloud.com>
* 2017, Arthur Schiwon <blizzz@arthur-schiwon.de>
* 2017, Thomas Citharel <tcit@tcit.fr>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
@ -294,6 +295,32 @@ $(document).ready(function () {
};
$("#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() {
location.reload();
},
fail: function() {
OC.Notification.showTemporary(t('settings', 'An error occured while changing your locale. Please reload the page and try again.'));
}
});
};
$("#localeinput").change(updateLocale);
var uploadparms = {
pasteZone: null,
done: function (e, data) {

@ -3,6 +3,7 @@
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Thomas Citharel <tcit@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
@ -379,3 +380,29 @@ vendor_style('jcrop/css/jquery.Jcrop');
</div>
</div>
<form id="locale" class="section">
<h2>
<label for="localeinput"><?php p($l->t('Locale'));?></label>
</h2>
<select id="localeinput" name="lang" data-placeholder="<?php p($l->t('Locale'));?>">
<option value="<?php p($_['activelocale']['code']);?>">
<?php p($_['activelocale']['name']);?>
</option>
<optgroup label="––––––––––"></optgroup>
<?php foreach($_['localesforlanguage'] as $locale):?>
<option value="<?php p($locale['code']);?>">
<?php p($locale['name']);?>
</option>
<?php endforeach;?>
<optgroup label="––––––––––"></optgroup>
<option value="<?php p($_['activelocale']['code']);?>">
<?php p($_['activelocale']['name']);?>
</option>
<?php foreach($_['locales'] as $locale):?>
<option value="<?php p($locale['code']);?>">
<?php p($locale['name']);?>
</option>
<?php endforeach;?>
</select>
</form>

Loading…
Cancel
Save