Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add some basic verification when loading the languages config file

  • Loading branch information...
commit 52522c102e7995226c7ce1d288a1b58358d5e51d 1 parent c4d8f4e
@jguyon jguyon authored
View
1  app/controllers/application_controller.rb
@@ -35,6 +35,7 @@ def set_invites
end
def set_locale
+ I18n.default_locale = DEFAULT_LANGUAGE
if current_user
I18n.locale = current_user.language
else
View
6 config/environment.rb
@@ -21,9 +21,9 @@
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'
Please sign in to comment.
Something went wrong with that request. Please try again.