Question

I've got an app with multiple deployments in different languages. In order to streamline testing and deployment I'd like to write a quick rake task that sets the locale.

I've tried different ways but I'm stuck actually accessing i18n.default_locale from the Rake task.

I'd like to do something like

bundle exec rake locale:set the_locale_to_switch_to

So far I've got (full of syntax errors)

task :set, [:locale_name]  => :environment  do |t, args|
  new_locale = args.locale_name
  puts "Changing locale to #{new_locale}"
  ApplicationController.config.I18n.default_locale = new_locale
  puts "locale is #{ApplicationController.config.I18n.default_locale}"
end

Any way to do that? I'd like to modify an already-deployed app if possible... am I going the right way?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top