Sha256: 8d9ca0994c970674cca7d4d295df51c78207b80dcce1c4392c51de79ac34744b

Contents?: true

Size: 536 Bytes

Versions: 4

Compression:

Stored size: 536 Bytes

Contents

# frozen_string_literal: true
module I18n::Tasks
  module LocaleList
    extend self

    # @return locales converted to strings, with base locale first, the rest sorted alphabetically
    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])
      else
        if include_base
          [base_locale] + locales
        else
          locales
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i18n-tasks-0.9.6 lib/i18n/tasks/locale_list.rb
i18n-tasks-0.9.5 lib/i18n/tasks/locale_list.rb
i18n-tasks-0.9.4 lib/i18n/tasks/locale_list.rb
i18n-tasks-0.9.3 lib/i18n/tasks/locale_list.rb