module RailsCountries::ActionView::Helpers

Public Instance Methods

countries_alpha2_options(locale = nil) click to toggle source
# File lib/rails-countries/helpers.rb, line 6
def countries_alpha2_options(locale = nil)
  ISO3166::Country.all.map { |country| [country.translation(locale || I18n.locale), country.alpha2] }
end
countries_alpha3_options(locale = nil) click to toggle source
# File lib/rails-countries/helpers.rb, line 10
def countries_alpha3_options(locale = nil)
  ISO3166::Country.all.map { |country| [country.translation(locale || I18n.locale), country.alpha3] }
end
i18n_country_name_by_alpha2(alpha2, locale = nil) click to toggle source
# 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) click to toggle source
# 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