File: translations.rb

package info (click to toggle)
ruby-countries 4.2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,196 kB
  • sloc: ruby: 2,085; makefile: 4
file content (11 lines) | stat: -rw-r--r-- 344 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
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