Inconsistent locale selection in admin and user settings

(Sawood Alam) #1

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 is changed from valueAttribute="value" to valueAttribute="name".

(Sawood Alam) #2

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

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

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

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

Which is a pipe separated string of language values.

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:

def self.available_locales{ |e| e[:value] }.join('|')

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

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"}]

(Sawood Alam) #3

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

(Jonathan Allard) #4

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

(Daler) #5

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):