Skip to content

Commit

Permalink
Merge pull request #264 from wvengen/feature-config_default_locale
Browse files Browse the repository at this point in the history
add configuration for default language
  • Loading branch information
wvengen committed Mar 15, 2014
2 parents 4fa2d22 + d8f6bc7 commit bb9af1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions config/app_config.yml.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions lib/foodsoft/controller_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ def browser_language
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

Expand All @@ -52,4 +53,4 @@ def set_locale

end
end
end
end

0 comments on commit bb9af1f

Please sign in to comment.