Skip to content

Commit

Permalink
Merge pull request consuldemocracy#1718 from consul/migrate_locales
Browse files Browse the repository at this point in the history
Migrate localization files & Prepare Crowdin
  • Loading branch information
bertocq authored Jul 5, 2017
2 parents e990568 + f58f033 commit e8e6eff
Show file tree
Hide file tree
Showing 85 changed files with 60 additions and 24 deletions.
4 changes: 2 additions & 2 deletions CUSTOMIZE_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CUSTOMIZE_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Application < Rails::Application
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")

Expand All @@ -41,7 +43,6 @@ class Application < Rails::Application
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

Expand Down
34 changes: 17 additions & 17 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 15 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions lib/tasks/locales.rake
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e8e6eff

Please sign in to comment.