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/config/application.rb b/config/application.rb index 2b842992b..ea799001e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,10 +20,8 @@ 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] - - # Add the new directories to the locales load path + config.i18n.available_locales = [:en, :es, :fr, 'pt-BR'] + config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es'} config.assets.paths << Rails.root.join("app", "assets", "fonts") @@ -44,7 +42,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/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 diff --git a/doc/locales/fr.yaml b/config/locales/fr.yml similarity index 100% rename from doc/locales/fr.yaml rename to config/locales/fr.yml diff --git a/doc/locales/pt-br.yaml b/config/locales/pt-BR.yml similarity index 99% rename from doc/locales/pt-br.yaml rename to config/locales/pt-BR.yml index 9d2b3ee46..f3159cdc2 100644 --- a/doc/locales/pt-br.yaml +++ b/config/locales/pt-BR.yml @@ -1,5 +1,8 @@ --- pt-BR: + i18n: + language: + name: Português account: show: change_credentials_link: Alterar meus dados pessoais