Module: RailsCountries::ActionView::Helpers
- Defined in:
- lib/rails-countries/helpers.rb
Instance Method Summary collapse
- #countries_alpha2_options(locale = nil) ⇒ Object
- #countries_alpha3_options(locale = nil) ⇒ Object
- #i18n_country_name_by_alpha2(alpha2, locale = nil) ⇒ Object
- #i18n_country_name_by_alpha3(alpha3, locale = nil) ⇒ Object
Instance Method Details
#countries_alpha2_options(locale = nil) ⇒ Object
6 7 8 |
# File 'lib/rails-countries/helpers.rb', line 6 def (locale = nil) ISO3166::Country.all.map { |country| [country.translation(locale || I18n.locale), country.alpha2] } end |
#countries_alpha3_options(locale = nil) ⇒ Object
10 11 12 |
# File 'lib/rails-countries/helpers.rb', line 10 def (locale = nil) ISO3166::Country.all.map { |country| [country.translation(locale || I18n.locale), country.alpha3] } end |
#i18n_country_name_by_alpha2(alpha2, locale = nil) ⇒ Object
14 15 16 |
# File 'lib/rails-countries/helpers.rb', line 14 def i18n_country_name_by_alpha2(alpha2, locale = nil) ISO3166::Country.new(alpha2)&.translation(locale || I18n.locale) end |
#i18n_country_name_by_alpha3(alpha3, locale = nil) ⇒ Object
18 19 20 |
# File 'lib/rails-countries/helpers.rb', line 18 def i18n_country_name_by_alpha3(alpha3, locale = nil) ISO3166::Country.find_country_by_alpha3(alpha3)&.translation(locale || I18n.locale) end |