Module: I18n::Tasks::LocaleList

Defined in:
lib/i18n/tasks/locale_list.rb

Class Method Summary collapse

Class Method Details

.normalize_locale_list(locales, base_locale, include_base = false) ⇒ Object

Returns locales converted to strings, with base locale first, the rest sorted alphabetically.

Returns:

  • locales converted to strings, with base locale first, the rest sorted alphabetically



8
9
10
11
12
13
14
15
16
17
# File 'lib/i18n/tasks/locale_list.rb', line 8

def normalize_locale_list(locales, base_locale, include_base = false)
  locales = Array(locales).map(&:to_s).sort
  if locales.include?(base_locale)
    [base_locale] + (locales - [base_locale])
  elsif include_base
    [base_locale] + locales
  else
    locales
  end
end