# Inconsistent locale selection in admin and user settings

**URL:** https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773
**Category:** Bug
**Created:** [December 4, 2016, 10:49pm UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773 "2016-12-04T22:49:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 4, 2016, 10:49pm UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773/1 "2016-12-04T22:49:49Z")

</div>

In the admin section, “default locale” selection combo-box shows names of languages such as “Deutsch” and “English”. However, if the “allow user locale” is enables, the “interface language” selection combo-box shows language values instead, such as “de” and “en”.

I think it would be fixed if [preferences.hbs#L125](https://github.com/discourse/discourse/blob/a94f06ff7843bdd9b3904c73ad97e522f666ef11/app/assets/javascripts/discourse/templates/preferences.hbs#L125) is changed from `valueAttribute="value"` to `valueAttribute="name"`.

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 4, 2016, 11:18pm UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773/2 "2016-12-04T23:18:45Z")

</div>

It looks like the issue is more deep rooted and requires further changes.

```hbs
{{combo-box valueAttribute="value" content=availableLocales value=model.locale none="user.locale.default"}}

```

This populates data from the `availableLocales` which is defined like this:

```js
availableLocales() {
  return this.siteSettings.available_locales.split('|').map(s => ({ name: s, value: s }));
}

```

Which is a pipe separated string of language values.

```irb
pry(main)> SiteSetting.available_locales
=> "ar|bs_BA|cs|da|de|en|es|et|fa_IR|fi|fr|gl|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ro|ru|sk|sq|sv|te|tr_TR|uk|vi|zh_CN|zh_TW"

```

Because it is generated like this:

```ruby
def self.available_locales
  LocaleSiteSetting.values.map{ |e| e[:value] }.join('|')
end

```

On the the names and values both were available, but only values were pushed in the `client_settings`.

```irb
pry(main)> LocaleSiteSetting.values
=> [{:name=>"اللغة العربية", :value=>"ar"},
 {:name=>"bosanski jezik", :value=>"bs_BA"},
 {:name=>"čeština", :value=>"cs"},
 {:name=>"dansk", :value=>"da"},
 {:name=>"Deutsch", :value=>"de"},
 {:name=>"English", :value=>"en"},
 {:name=>"Español", :value=>"es"},
 {:name=>"eesti", :value=>"et"},
 {:name=>"فارسی", :value=>"fa_IR"},
 {:name=>"suomi", :value=>"fi"},
 {:name=>"Français", :value=>"fr"},
 {:name=>"galego", :value=>"gl"},
 {:name=>"עברית", :value=>"he"},
 {:name=>"Indonesian", :value=>"id"},
 {:name=>"Italiano", :value=>"it"},
 {:name=>"日本語", :value=>"ja"},
 {:name=>"한국어", :value=>"ko"},
 {:name=>"Norsk bokmål", :value=>"nb_NO"},
 {:name=>"Nederlands", :value=>"nl"},
 {:name=>"język polski", :value=>"pl_PL"},
 {:name=>"Português", :value=>"pt"},
 {:name=>"Português (BR)", :value=>"pt_BR"},
 {:name=>"limba română", :value=>"ro"},
 {:name=>"Русский", :value=>"ru"},
 {:name=>"slovenčina", :value=>"sk"},
 {:name=>"Shqip", :value=>"sq"},
 {:name=>"svenska", :value=>"sv"},
 {:name=>"తెలుగు", :value=>"te"},
 {:name=>"Türkçe", :value=>"tr_TR"},
 {:name=>"українська мова", :value=>"uk"},
 {:name=>"Việt Nam", :value=>"vi"},
 {:name=>"中文", :value=>"zh_CN"},
 {:name=>"中文 (TW)", :value=>"zh_TW"}]

```

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 4, 2016, 11:50pm UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773/3 "2016-12-04T23:50:26Z")

</div>

I was able to dig down the PR by @joallard responsible for adding this feature.

[https://github.com/discourse/discourse/pull/1922](https://github.com/discourse/discourse/pull/1922)

---

<div class="post-metadata">

### Author: ![joallard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joallard/32/174559_2.png) [@joallard](https://meta.discourse.org/u/joallard)
#### Post date: [December 5, 2016, 1:30am UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773/4 "2016-12-05T01:30:18Z")

</div>

Hi! Yep, sounds like an easy fix. We’d just have to send the full objects from upstream, and then display the labels properly.

---

<div class="post-metadata">

### Author: ![dalerka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dalerka/32/120265_2.png) [@dalerka](https://meta.discourse.org/u/dalerka)
#### Post date: [October 25, 2017, 8:29am UTC](https://meta.discourse.org/t/inconsistent-locale-selection-in-admin-and-user-settings/53773/5 "2017-10-25T08:29:46Z")

</div>

Hi and thank you for this feature! Has this issue been fixed or is there any progress?

Seems a related topic here (apparently still awayting PR):

> [@Is there any way to let language selector display 'English' instead of 'en'?](https://meta.discourse.org/t/is-there-any-way-to-let-language-selector-display-english-instead-of-en/14518/6):
>
> This is now complete in the admin section. Per: If admins enables user locales then we don’t get it cry However user locale selection is kind of rare, #pr-welcome to make the user selector consistent with admin.
