diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ab2838c2..3e32d4c27 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,6 +35,7 @@ class ApplicationController < ActionController::Base end def set_locale + I18n.default_locale = DEFAULT_LANGUAGE if current_user I18n.locale = current_user.language else diff --git a/config/environment.rb b/config/environment.rb index e95579b99..9afe20c52 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -21,9 +21,9 @@ end if File.exists?(File.expand_path("./config/languages.yml")) languages = YAML::load(File.open(File.expand_path("./config/languages.yml"))) - AVAILABLE_LANGUAGES = languages['available'] - DEFAULT_LANGUAGE = languages['default'] - AVAILABLE_LANGUAGE_CODES = languages['available'].keys.map { |v| v.to_s} + AVAILABLE_LANGUAGES = (languages['available'].length > 0) ? languages['available'] : { :en => 'English' } + DEFAULT_LANGUAGE = (AVAILABLE_LANGUAGES.include?(languages['default'])) ? languages['default'] : AVAILABLE_LANGUAGES.keys[0].to_s + AVAILABLE_LANGUAGE_CODES = languages['available'].keys.map { |v| v.to_s } else AVAILABLE_LANGUAGES = { :en => 'English' } DEFAULT_LANGUAGES = 'en'