Commit b6108f3c8d9033375aaa5c5fce0d71bc839dad21
1 parent
ece6c563
Exists in
master
and in
21 other branches
Moves custom_locales to config/custom_locales
Showing
2 changed files
with
17 additions
and
16 deletions
Show diff stats
INSTALL.locales.md
| 1 | Using custom locales | 1 | Using custom locales |
| 2 | ==================== | 2 | ==================== |
| 3 | 3 | ||
| 4 | -Personalized translations go into the `custom_locales/` directory. Custom | ||
| 5 | -locales can be identified by the rails environment, schema name in a | 4 | +Personalized translations go into the `config/custom_locales/` directory. |
| 5 | +Custom locales can be identified by the rails environment, schema name in a | ||
| 6 | multitenancy setup or domain name until the first dot (e.g env1.coop.br for the | 6 | multitenancy setup or domain name until the first dot (e.g env1.coop.br for the |
| 7 | example below). | 7 | example below). |
| 8 | 8 | ||
| @@ -13,16 +13,17 @@ processed is "environment". For instance, a POT file would be called | @@ -13,16 +13,17 @@ processed is "environment". For instance, a POT file would be called | ||
| 13 | The structure of an environment named env1 with custom translations for both | 13 | The structure of an environment named env1 with custom translations for both |
| 14 | Portuguese and Spanish and an environment named env2 with custom Russian | 14 | Portuguese and Spanish and an environment named env2 with custom Russian |
| 15 | translation would be: | 15 | translation would be: |
| 16 | - | ||
| 17 | - custom_locales/ | ||
| 18 | - env1/ | ||
| 19 | - environment.pot | ||
| 20 | - pt/ | ||
| 21 | - environment.po | ||
| 22 | - es/ | ||
| 23 | - environment.po | ||
| 24 | - env2/ | ||
| 25 | - environment.pot | ||
| 26 | - ru/ | ||
| 27 | - environment.po | 16 | + |
| 17 | + config/ | ||
| 18 | + custom_locales/ | ||
| 19 | + env1/ | ||
| 20 | + environment.pot | ||
| 21 | + pt/ | ||
| 22 | + environment.po | ||
| 23 | + es/ | ||
| 24 | + environment.po | ||
| 25 | + env2/ | ||
| 26 | + environment.pot | ||
| 27 | + ru/ | ||
| 28 | + environment.po | ||
| 28 | 29 |
lib/noosfero/i18n.rb
| @@ -8,7 +8,7 @@ end | @@ -8,7 +8,7 @@ end | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | # Adds custom locales for a whole environment | 10 | # Adds custom locales for a whole environment |
| 11 | -custom_locale_dir = Rails.root.join('custom_locales', Rails.env) | 11 | +custom_locale_dir = Rails.root.join('config', 'custom_locales', Rails.env) |
| 12 | repos = [] | 12 | repos = [] |
| 13 | if File.exists?(custom_locale_dir) | 13 | if File.exists?(custom_locale_dir) |
| 14 | repos << FastGettext::TranslationRepository.build('environment', :type => 'po', :path => custom_locale_dir) | 14 | repos << FastGettext::TranslationRepository.build('environment', :type => 'po', :path => custom_locale_dir) |
| @@ -30,7 +30,7 @@ hosted_environments = Noosfero::MultiTenancy.mapping.values | @@ -30,7 +30,7 @@ hosted_environments = Noosfero::MultiTenancy.mapping.values | ||
| 30 | hosted_environments += Domain.all.map { |domain| domain.name[/(.*?)\./,1] } if Domain.table_exists? | 30 | hosted_environments += Domain.all.map { |domain| domain.name[/(.*?)\./,1] } if Domain.table_exists? |
| 31 | 31 | ||
| 32 | hosted_environments.uniq.each do |env| | 32 | hosted_environments.uniq.each do |env| |
| 33 | - custom_locale_dir = Rails.root.join('custom_locales', env) | 33 | + custom_locale_dir = Rails.root.join('config', 'custom_locales', env) |
| 34 | if File.exists?(custom_locale_dir) | 34 | if File.exists?(custom_locale_dir) |
| 35 | FastGettext.add_text_domain(env, :type => :chain, :chain => [FastGettext::TranslationRepository.build('environment', :type => 'po', :path => custom_locale_dir)] + repos) | 35 | FastGettext.add_text_domain(env, :type => :chain, :chain => [FastGettext::TranslationRepository.build('environment', :type => 'po', :path => custom_locale_dir)] + repos) |
| 36 | end | 36 | end |