Fix language sorting in settings (#27158)
This commit is contained in:
parent
c676bc91e9
commit
68ec1d180a
4 changed files with 50 additions and 2 deletions
|
@ -230,6 +230,24 @@ module LanguagesHelper
|
|||
'sr-Latn': 'Srpski (latinica)',
|
||||
}.freeze
|
||||
|
||||
# Helper for self.sorted_locale_keys
|
||||
private_class_method def self.locale_name_for_sorting(locale)
|
||||
if locale.blank? || locale == 'und'
|
||||
'000'
|
||||
elsif (supported_locale = SUPPORTED_LOCALES[locale.to_sym])
|
||||
ASCIIFolding.new.fold(supported_locale[1]).downcase
|
||||
elsif (regional_locale = REGIONAL_LOCALE_NAMES[locale.to_sym])
|
||||
ASCIIFolding.new.fold(regional_locale).downcase
|
||||
else
|
||||
locale
|
||||
end
|
||||
end
|
||||
|
||||
# Sort locales by native name for dropdown menus
|
||||
def self.sorted_locale_keys(locale_keys)
|
||||
locale_keys.sort_by { |key, _| locale_name_for_sorting(key) }
|
||||
end
|
||||
|
||||
def native_locale_name(locale)
|
||||
if locale.blank? || locale == 'und'
|
||||
I18n.t('generic.none')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue