From b617ee1dca477e5ff9c6e69a44fab502940c4df9 Mon Sep 17 00:00:00 2001 From: echarp Date: Thu, 25 Apr 2019 10:36:33 +0200 Subject: [PATCH] Country names are translated to the browser language --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/views/regions/_filter_region.haml | 5 +++-- app/views/regions/_selector_region.haml | 5 +++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index aefa3a9d..3eb10ec7 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ gem 'kramdown' gem 'flag-icons-rails' gem 'geocoder' +gem 'i18n-country-translations' # Tiny MCE integration gem 'tinymce-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 0e3e8054..0adfd9a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -196,6 +196,9 @@ GEM concurrent-ruby (~> 1.0) i18n-active_record (0.2.2) i18n (>= 0.5.0) + i18n-country-translations (1.3.1) + i18n (>= 0.9.3, < 2) + railties (>= 5.0, < 5.3) icalendar (2.5.3) ice_cube (~> 0.16) inherited_resources (1.10.0) @@ -464,6 +467,7 @@ DEPENDENCIES high_voltage http_accept_language i18n-active_record + i18n-country-translations icalendar ice_cube! jbuilder (~> 2.5) diff --git a/app/views/regions/_filter_region.haml b/app/views/regions/_filter_region.haml index 3e31a43f..c423fbcf 100644 --- a/app/views/regions/_filter_region.haml +++ b/app/views/regions/_filter_region.haml @@ -3,7 +3,7 @@ = link_to filter_region.url do - if filter_region.code.present? = flag_icon filter_region.code.downcase - = filter_region.name + = t filter_region.code, scope: :countries, default: filter_region.name %small %em.fa.fa-external-link-alt - else @@ -11,9 +11,10 @@ region: params[:region] == filter_region.id.to_s ? '' : filter_region do - if filter_region.code.present? = flag_icon filter_region.code.downcase + = t filter_region.code, scope: :countries, default: filter_region.name - else %em.fa.fa-shield-alt - = filter_region.name + = filter_region.name - if params[:region] == filter_region.id.to_s %em.fa.fa-times - elsif !filter_region.region && filter_region.regions.present? diff --git a/app/views/regions/_selector_region.haml b/app/views/regions/_selector_region.haml index c05da8ba..53e30e47 100644 --- a/app/views/regions/_selector_region.haml +++ b/app/views/regions/_selector_region.haml @@ -1,12 +1,13 @@ - if selector_region.regions.present? || selector_region.url.blank? - %span.region{ title: selector_region } + %span.region{ title: selector_region.code } = f.radio_button :region_id, selector_region.id = f.label "region_id_#{selector_region.id}" do - if selector_region.code.present? = flag_icon selector_region.code.downcase + = t selector_region.code, scope: :countries, default: selector_region.name - else %em.fa.fa-map - = selector_region + = selector_region - if selector_region.regions.present? %small %em.fa.fa-chevron-right