Merge pull request #2128 from mkllnk/2113-i18n-config

2113 Display only selected languages in switcher
This commit is contained in:
Pau Pérez Fabregat
2018-03-23 15:06:47 +01:00
committed by GitHub
6 changed files with 151 additions and 25 deletions

View File

@@ -0,0 +1,27 @@
module OpenFoodNetwork
# Provides access to the language settings.
# Currently, language settings are read from the environment.
# See: config/application.yml
class I18nConfig
# Locales that can be selected by users.
def self.selectable_locales
ENV["AVAILABLE_LOCALES"].andand.split(/[\s,]+/) || []
end
# All locales that can be accessed by the application, including fallbacks.
def self.available_locales
(selectable_locales + [default_locale, source_locale]).uniq
end
# The default locale that is used when the user doesn't have a preference.
def self.default_locale
ENV["LOCALE"] || ENV["I18N_LOCALE"] || source_locale
end
# This locale is changed with the code and should always be complete.
# All translations are done from this locale.
def self.source_locale
"en"
end
end
end