Merge pull request #6460 from tchak/fix-add-kosovo
fix(i18n): add Kosovo to countries list
This commit is contained in:
commit
188c1e70a8
3 changed files with 18 additions and 2 deletions
|
@ -2,7 +2,7 @@ class API::PaysController < ApplicationController
|
|||
before_action :authenticate_logged_user!
|
||||
|
||||
def index
|
||||
countries = I18nData.countries('FR').zip(I18nData.countries(I18n.locale))
|
||||
countries = CountriesService.get('FR').zip(CountriesService.get(I18n.locale))
|
||||
countries = countries.map do |(code, value_fr), (localized_code, localized_value)|
|
||||
if code != localized_code
|
||||
raise "Countries lists mismatch. It means i18n_data gem has some internal inconsistencies."
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
class Champs::PaysChamp < Champs::TextChamp
|
||||
def localized_value
|
||||
if external_id
|
||||
I18nData.countries(I18n.locale)[external_id].to_s
|
||||
CountriesService.get(I18n.locale)[external_id].to_s
|
||||
else
|
||||
value.present? ? value.to_s : ''
|
||||
end
|
||||
|
|
16
app/services/countries_service.rb
Normal file
16
app/services/countries_service.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class CountriesService
|
||||
def self.get(locale)
|
||||
I18nData.countries(locale).merge(get_localized_additional_countries(locale))
|
||||
end
|
||||
|
||||
def self.get_localized_additional_countries(locale)
|
||||
additional_countries[locale.to_s.upcase] || {}
|
||||
end
|
||||
|
||||
def self.additional_countries
|
||||
{
|
||||
'FR' => { 'XK' => 'Kosovo' },
|
||||
'EN' => { 'XK' => 'Kosovo' }
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue