diff options
-rw-r--r-- | config/environments/development.rb | 3 | ||||
-rw-r--r-- | config/initializers/i18n.rb | 6 | ||||
-rw-r--r-- | lib/tasks/i18n.rake | 13 |
3 files changed, 20 insertions, 2 deletions
diff --git a/config/environments/development.rb b/config/environments/development.rb index 7b06c81..f088ef2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -22,6 +22,9 @@ LeapWeb::Application.configure do # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true # Do not compress assets config.assets.compress = false diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 645e370..ad8edd5 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -6,3 +6,9 @@ I18n.load_path += Dir[Rails.root.join('config', 'locales', 'en', '*.yml')] # enable using the cascade option # see svenfuchs.com/2011/2/11/organizing-translations-with-i18n-cascade-and-i18n-missingtranslations I18n::Backend::Simple.send(:include, I18n::Backend::Cascade) + +# can't get this working +# I18n.available_locales << :'pt-BR' +#require "i18n/backend/fallbacks" +#I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) +#I18n.fallbacks.map(:ca => :es, :pt => :'pt-BR')
\ No newline at end of file diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index b026fae..896f67e 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -47,6 +47,12 @@ namespace :i18n do end end + # + # I have not been able to get fallback from :pt => :'pt-BR' working. + # The rails guide implies that it does not work, even though I18n has + # a fallback mechanism. + # For now, just use a single language for ever locale. + # LOCALE_ALIAS_MAP = { :nb => 'nb-no', :pt => 'pt-br' @@ -65,8 +71,11 @@ namespace :i18n do next if lang == :en puts puts "downloading #{lang}" - lang_url = LOCALE_ALIAS_MAP[lang] || lang - command = %[curl -L --netrc-file transifex.netrc -X GET 'https://www.transifex.com/api/2/project/bitmask/resource/leap_web/translation/#{lang_url}/?file' > locales/#{lang}.yml] + lang_url_segment = LOCALE_ALIAS_MAP[lang] || lang + url = "https://www.transifex.com/api/2/project/bitmask/resource/leap_web/translation/#{lang_url_segment}/?file" + command = %[echo "#{lang}:" > locales/#{lang}.yml && ]+ + %[curl -L --netrc-file transifex.netrc -X GET '#{url}' ]+ + %[| tail -n +2 >> locales/#{lang}.yml] puts command `#{command}` end |