Sha256: fad3f4a22c1256394bfb0d93fb976be32b74e8063707aca952c2db95e85c0252

Contents?: true

Size: 344 Bytes

Versions: 3

Compression:

Stored size: 344 Bytes

Contents

module ISO3166
  # Extend the hash class to allow locale lookup fall back behavior
  #
  # E.g. if a country has translations for +pt+, and the user looks up +pt-br+ fallback
  # to +pt+ to prevent from showing nil values
  class Translations < Hash
    def [](locale)
      super(locale) || super(locale.to_s.sub(/-.*/, ''))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
countries-4.2.3 lib/countries/translations.rb
countries-4.2.2 lib/countries/translations.rb
countries-4.2.1 lib/countries/translations.rb