Merge pull request #1718 from consul/migrate_locales

Migrate localization files & Prepare Crowdin
This commit is contained in:
BertoCQ
2017-07-05 14:29:45 +02:00
committed by GitHub
85 changed files with 60 additions and 24 deletions

View File

@@ -32,7 +32,7 @@ If you just want to change some of the existing texts, you can just drop your ch
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
And that the text its located at the file `config/locales/es.yml` following this structure (we're only displaying in the following snippet the relevant parts):
And that the text its located at the file `config/locales/es/general.yml` following this structure (we're only displaying in the following snippet the relevant parts):
```yml
es:
@@ -42,7 +42,7 @@ es:
```
So in order to customize it, we would create a new file `config/locales/custom/es.yml` with just that content, and change "Ayuntamiento de Madrid" for our organization name. We strongly recommend to make copies from `config/locales/` and modify or delete the lines as needed to keep the indentation structure and avoid issues.
So in order to customize it, we would create a new file `config/locales/custom/es/general.yml` with just that content, and change "Ayuntamiento de Madrid" for our organization name. We strongly recommend to make copies from `config/locales/` and modify or delete the lines as needed to keep the indentation structure and avoid issues.
### Images

View File

@@ -32,7 +32,7 @@ Las adaptaciones los debes poner en el directorio `config/locales/custom/`, reco
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
Y que en el fichero `config/locales/es.yml` sigue esta estructura (solo ponemos lo relevante para este caso):
Y que en el fichero `config/locales/es/general.yml` sigue esta estructura (solo ponemos lo relevante para este caso):
```yml
es:
@@ -42,7 +42,7 @@ es:
```
Si creamos el fichero `config/locales/custom/es.yml` y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros `config/locales/` e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir.
Si creamos el fichero `config/locales/custom/es/general.yml` y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros `config/locales/` e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir.
### Imágenes

View File

@@ -22,6 +22,8 @@ module Consul
config.i18n.default_locale = :es
config.i18n.available_locales = [:en, :es, :fr, :nl, 'pt-BR']
config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es', 'nl' => 'en'}
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'custom', '**', '*.{rb,yml}')]
config.assets.paths << Rails.root.join("app", "assets", "fonts")
@@ -41,7 +43,6 @@ module Consul
config.autoload_paths << "#{Rails.root}/app/controllers/custom"
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

View File

@@ -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: [en, es]
locales: [en]
## Reporting locale, default: en. Available: en, ru.
# internal_locale: en
@@ -21,22 +21,22 @@ data:
# - config/locales/**/*.%{locale}.yml
## Another gem (replace %#= with %=):
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
- config/locales/%{locale}.yml
- config/locales/activerecord.%{locale}.yml
- config/locales/activemodel.%{locale}.yml
- config/locales/admin.%{locale}.yml
- config/locales/moderation.%{locale}.yml
- config/locales/valuation.%{locale}.yml
- config/locales/management.%{locale}.yml
- config/locales/verification.%{locale}.yml
- config/locales/mailers.%{locale}.yml
- config/locales/pages.%{locale}.yml
- config/locales/devise_views.%{locale}.yml
- config/locales/responders.%{locale}.yml
- config/locales/kaminari.%{locale}.yml
- config/locales/officing.%{locale}.yml
- config/locales/budgets.%{locale}.yml
- config/locales/legislation.%{locale}.yml
- config/locales/%{locale}/general.yml
- config/locales/%{locale}/activerecord.yml
- config/locales/%{locale}/activemodel.yml
- config/locales/%{locale}/admin.yml
- config/locales/%{locale}/moderation.yml
- config/locales/%{locale}/valuation.yml
- config/locales/%{locale}/management.yml
- config/locales/%{locale}/verification.yml
- config/locales/%{locale}/mailers.yml
- config/locales/%{locale}/pages.yml
- config/locales/%{locale}/devise_views.yml
- config/locales/%{locale}/responders.yml
- config/locales/%{locale}/kaminari.yml
- config/locales/%{locale}/officing.yml
- config/locales/%{locale}/budgets.yml
- config/locales/%{locale}/legislation.yml
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
# `i18n-tasks normalize -p` will force move the keys according to these rules

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -1,3 +1,16 @@
files:
- source: /config/locales/*.en.yml
translation: /config/locales/%two_letters_code%/%original_file_name%
- source: /config/locales/en/**.yml
translation: /config/locales/%locale%/%original_file_name%
languages_mapping:
locale:
ar: ar
ast: ast
ca: ca
es-ES: es
fr: fr
gl: gl
he: he
it: it
nl: nl
pt-PT: pt
ru: ru

22
lib/tasks/locales.rake Normal file
View File

@@ -0,0 +1,22 @@
namespace :locales do
desc 'Migrate all localization files to new structure for a given locale name as argument'
task :migrate_structure, [:locale] => [:environment] do |_t, args|
locale = args[:locale]
puts "Moving files for locale: #{locale}"
# This creates ./config/locales/en/ directory
system "mkdir ./config/locales/#{locale}"
# This moves from ./config/locales/en.yml to ./config/locales/en/general.yml
system "mv ./config/locales/#{locale}.yml ./config/locales/#{locale}/general.yml"
# This moves from ./config/locales/admin.en.yml to ./config/locales/en/admin.en.yml
system "mv ./config/locales/*.#{locale}.yml ./config/locales/#{locale}/"
# This moves from ./config/locales/en/admin.en.yml to ./config/locales/en/admin.yml
system "find ./config/locales/ -name \"*.#{locale}.yml\" -exec sh -c 'mv \"$1\" \"${1%.#{locale}.yml}.yml\"' _ {} \\;"
puts "Moved!"
end
end