From 03585e272f8dd249d636fd062656d6c29c4ff870 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 21 Feb 2014 14:28:27 +0100 Subject: [PATCH] add configuration for default language --- config/app_config.yml.SAMPLE | 7 +++++++ lib/foodsoft/controller_extensions.rb | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/app_config.yml.SAMPLE b/config/app_config.yml.SAMPLE index 2a4b38db..dc7c74be 100644 --- a/config/app_config.yml.SAMPLE +++ b/config/app_config.yml.SAMPLE @@ -34,6 +34,13 @@ default: &defaults # documentation URL for the apples&pears work system applepear_url: https://github.com/foodcoops/foodsoft/wiki/%C3%84pfel-u.-Birnen + # Default language + #default_locale: en + # By default, foodsoft takes the language from the webbrowser/operating system. + # In case you really want foodsoft in a certain language by default, set this to true. + # When members are logged in, the language from their profile settings is still used. + #ignore_browser_locale: false + # price markup in percent price_markup: 2.0 diff --git a/lib/foodsoft/controller_extensions.rb b/lib/foodsoft/controller_extensions.rb index e0b64aa6..3170556d 100644 --- a/lib/foodsoft/controller_extensions.rb +++ b/lib/foodsoft/controller_extensions.rb @@ -25,13 +25,14 @@ module Foodsoft end def default_language - ::I18n.default_locale + FoodsoftConfig[:default_locale] or ::I18n.default_locale end protected def select_language_according_to_priority - language = explicitly_requested_language || session_language || user_settings_language || browser_language + language = explicitly_requested_language || session_language || user_settings_language + language ||= browser_language unless FoodsoftConfig[:ignore_browser_locale] language.to_sym unless language.blank? end @@ -52,4 +53,4 @@ module Foodsoft end end -end \ No newline at end of file +end