about summary refs log tree commit diff
path: root/config
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2018-03-04 17:21:35 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-03-04 09:21:35 +0100
commit51d760960ccf0866eba32944434ba08b2cbe5092 (patch)
treef939652be42e519fd20eb4af7a4ebf32e95d45ca /config
parent9110db41c53a2f3f22affc23b364362133997d3e (diff)
Set the default locale in config (#6580)
Previously the default locale was set by Localized concern for controllers,
but it was not enforced for mailers.

config is enforced throughout the application and an appropriate place to
set the default locale.
Diffstat (limited to 'config')
-rw-r--r--config/application.rb9
-rw-r--r--config/environments/test.rb3
2 files changed, 10 insertions, 2 deletions
diff --git a/config/application.rb b/config/application.rb
index 34b9dcf48..097cbf567 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -31,7 +31,7 @@ module Mastodon
     # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
     # config.time_zone = 'Central Time (US & Canada)'
 
-    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+    # All translations from config/locales/*.rb,yml are auto loaded.
     # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
     config.i18n.available_locales = [
       :en,
@@ -73,7 +73,12 @@ module Mastodon
       :'zh-TW',
     ]
 
-    config.i18n.default_locale = :en
+    config.i18n.default_locale = ENV['DEFAULT_LOCALE']&.to_sym
+    if config.i18n.available_locales.include?(config.i18n.default_locale)
+      config.i18n.fallbacks = [:en]
+    else
+      config.i18n.default_locale = :en
+    end
 
     # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
     # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 20fe5f813..74e7fa694 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -51,6 +51,9 @@ Rails.application.configure do
 
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
+
+  config.i18n.default_locale = :en
+  config.i18n.fallbacks = true
 end
 
 Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension"