Sha256: b29555d89bd54331e74ddd8fa98f5a4b1173d38a0241800c2750884c22179330

Contents?: true

Size: 591 Bytes

Versions: 2

Compression:

Stored size: 591 Bytes

Contents

module TrustyCms::AvailableLocales
  # Returns the list of available locale files in options_for_select format.
  #
  def self.locales
    available_locales = {}
    TrustyCms.configuration.i18n.load_path.each do |path|
      if File.exist?(path) && path !~ /_available_tags/
        locale_yaml = YAML.load_file(path)
        stem = File.basename(path, '.yml')
        if locale_yaml[stem] && lang = locale_yaml[stem]['this_file_language']
          available_locales[lang] = stem
        end
      end
    end
    available_locales.collect { |k, v| [k, v] }.sort_by { |s| s[0] }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 lib/trusty_cms/available_locales.rb
trusty-cms-7.0.2 lib/trusty_cms/available_locales.rb