Class: ISO3166::Translations
- Inherits:
-
Hash
- Object
- Hash
- ISO3166::Translations
- Defined in:
- lib/countries/translations.rb
Overview
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
Also allows “indifferent access” to the hash, so you can use strings or symbols
Instance Method Summary collapse
Instance Method Details
#[](locale) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/countries/translations.rb', line 11 def [](locale) translations = locale.is_a?(String) ? super(locale.to_sym) : super return translations if translations super(locale.to_s.sub(/-.*/, '').to_sym) end |