Sha256: 20c02acd7a500bcc271feeea8b82c9beace7a4b9b255b8d201aa5f7e842de62c

Contents?: true

Size: 392 Bytes

Versions: 5

Compression:

Stored size: 392 Bytes

Contents

# frozen_string_literal: true

module CountrySelect
  FORMATS = {}

  FORMATS[:default] = lambda do |country|
    # Need to use :[] specifically, not :dig, because country.translations is a
    # ISO3166::Translations object, which overrides :[] to support i18n locale fallbacks
    country.translations&.send(:[], I18n.locale.to_s) || country.common_name || country.iso_short_name
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
country_select-10.0.1 lib/country_select/formats.rb
country_select-10.0.0 lib/country_select/formats.rb
country_select-9.0.0 lib/country_select/formats.rb
country_select-8.0.3 lib/country_select/formats.rb
country_select-8.0.2 lib/country_select/formats.rb