aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-07-18 17:10:31 +0100
committerLouise Crow <louise.crow@gmail.com>2013-07-18 17:43:26 +0100
commitbc0a6d54c4e5f3673a761ca434c49cbfebb89b09 (patch)
treeac7165739b51316122040be55d8ed5561f440ddf /lib
parent9fe48c5b9db1c0ba6c1a59f0d092c88e5cae1aa0 (diff)
Extract code for setting locales in FastGettext and I18n
Diffstat (limited to 'lib')
-rw-r--r--lib/alaveteli_localization.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/alaveteli_localization.rb b/lib/alaveteli_localization.rb
new file mode 100644
index 000000000..25de002c4
--- /dev/null
+++ b/lib/alaveteli_localization.rb
@@ -0,0 +1,13 @@
+class AlaveteliLocalization
+ class << self
+ def set_locales(available_locales, default_locale)
+ # fallback locale and available locales
+ available_locales = available_locales.split(/ /)
+ FastGettext.default_available_locales = available_locales
+ I18n.locale = default_locale
+ I18n.available_locales = available_locales.map { |locale_name| locale_name.to_sym }
+ I18n.default_locale = default_locale
+ end
+
+ end
+end