0
0
Fork 0

Fix language sorting in settings (#27158)

This commit is contained in:
gunchleoc 2023-10-04 08:23:50 +01:00 committed by GitHub
parent c676bc91e9
commit 68ec1d180a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 2 deletions

View file

@ -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')