From 04ca5f7ae8f5faf1db5a9bb390473149c97eb04b Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:50:07 +0100 Subject: [PATCH 1/5] adds french and brazilian portuguese locales --- config/application.rb | 6 +++--- doc/locales/{fr.yaml => fr.yml} | 0 doc/locales/{pt-br.yaml => pt-br.yml} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/locales/{fr.yaml => fr.yml} (100%) rename doc/locales/{pt-br.yaml => pt-br.yml} (100%) diff --git a/config/application.rb b/config/application.rb index 2b842992b..0da522fcf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,10 +20,11 @@ module Consul # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :es - - config.i18n.available_locales = [:en, :es] + config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] + config.i18n.fallbacks = {'fr' => 'en', 'pt-br' => 'en'} # Add the new directories to the locales load path + config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] config.assets.paths << Rails.root.join("app", "assets", "fonts") @@ -44,7 +45,6 @@ module Consul config.autoload_paths << "#{Rails.root}/app/models/custom" config.paths['app/views'].unshift(Rails.root.join('app', 'views', 'custom')) config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'custom', '*.{rb,yml}')] - end end diff --git a/doc/locales/fr.yaml b/doc/locales/fr.yml similarity index 100% rename from doc/locales/fr.yaml rename to doc/locales/fr.yml diff --git a/doc/locales/pt-br.yaml b/doc/locales/pt-br.yml similarity index 100% rename from doc/locales/pt-br.yaml rename to doc/locales/pt-br.yml From aeec264b8b5b3616d30c888a8068e5fdd749015d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 26 Oct 2016 11:21:51 +0200 Subject: [PATCH 2/5] makes fallback locale spanish --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 0da522fcf..8465f081a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,7 +21,7 @@ module Consul # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :es config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] - config.i18n.fallbacks = {'fr' => 'en', 'pt-br' => 'en'} + config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es'} # Add the new directories to the locales load path config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] From c0f400a4d99622b99e7f5f748b5f9c4ca17926a2 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:14:05 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Adds=20custom=20locale=20name=20for=20Portu?= =?UTF-8?q?gu=C3=AAs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/locales_helper.rb | 8 ++++++++ app/views/shared/_locale_switcher.html.erb | 2 +- doc/locales/pt-br.yml | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/helpers/locales_helper.rb diff --git a/app/helpers/locales_helper.rb b/app/helpers/locales_helper.rb new file mode 100644 index 000000000..7954cc908 --- /dev/null +++ b/app/helpers/locales_helper.rb @@ -0,0 +1,8 @@ +module LocalesHelper + + def name_for_locale(locale) + default = I18n.t("locale", locale: locale) + I18n.backend.translate(locale, "i18n.language.name", default: default) + end + +end diff --git a/app/views/shared/_locale_switcher.html.erb b/app/views/shared/_locale_switcher.html.erb index f29defcbd..af184fe48 100644 --- a/app/views/shared/_locale_switcher.html.erb +++ b/app/views/shared/_locale_switcher.html.erb @@ -8,7 +8,7 @@ <% I18n.available_locales.map do |loc| %> <% end %> diff --git a/doc/locales/pt-br.yml b/doc/locales/pt-br.yml index 9d2b3ee46..f3159cdc2 100644 --- a/doc/locales/pt-br.yml +++ b/doc/locales/pt-br.yml @@ -1,5 +1,8 @@ --- pt-BR: + i18n: + language: + name: Português account: show: change_credentials_link: Alterar meus dados pessoais From d540be333a1090dd6c17fbf8ece7156f91a487e8 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:45:14 +0100 Subject: [PATCH 4/5] Makes tolk aware of french and portuguese translations --- config/application.rb | 3 --- {doc => config}/locales/fr.yml | 0 doc/locales/pt-br.yml => config/locales/pt-BR.yml | 0 3 files changed, 3 deletions(-) rename {doc => config}/locales/fr.yml (100%) rename doc/locales/pt-br.yml => config/locales/pt-BR.yml (100%) diff --git a/config/application.rb b/config/application.rb index 8465f081a..ea799001e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,9 +23,6 @@ module Consul config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es'} - # Add the new directories to the locales load path - config.i18n.load_path += Dir[Rails.root.join('doc', 'locales', '*.yml')] - config.assets.paths << Rails.root.join("app", "assets", "fonts") # Do not swallow errors in after_commit/after_rollback callbacks. diff --git a/doc/locales/fr.yml b/config/locales/fr.yml similarity index 100% rename from doc/locales/fr.yml rename to config/locales/fr.yml diff --git a/doc/locales/pt-br.yml b/config/locales/pt-BR.yml similarity index 100% rename from doc/locales/pt-br.yml rename to config/locales/pt-BR.yml From 028cc4362d45d2ae961b1aae952b5ccaf03ac0d1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 31 Oct 2016 11:45:37 +0100 Subject: [PATCH 5/5] Makes i18n-tasks only aware of english and spanish locales --- config/i18n-tasks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 9cf9f8137..edaaa0958 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -3,7 +3,7 @@ # The "main" locale. base_locale: en ## All available locales are inferred from the data by default. Alternatively, specify them explicitly: -# locales: [es, fr] +locales: [en, es] ## Reporting locale, default: en. Available: en, ru. # internal_locale: en