Module: Bridgetown::Site::Localizable
- Included in:
- Bridgetown::Site
- Defined in:
- lib/bridgetown-core/concerns/site/localizable.rb
Instance Method Summary collapse
-
#locale ⇒ Object
Returns the current and/or default configured locale.
-
#locale=(new_locale) ⇒ Object
Sets the current locale for the site.
Instance Method Details
#locale ⇒ Object
Returns the current and/or default configured locale
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bridgetown-core/concerns/site/localizable.rb', line 7 def locale @locale ||= begin locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym I18n.load_path += Dir["#{in_source_dir("_locales")}/**/*.{json,rb,yml}"] I18n.available_locales = config[:available_locales] I18n.default_locale = locale I18n.fallbacks = [locale, :en].uniq locale end end |
#locale=(new_locale) ⇒ Object
Sets the current locale for the site
20 21 22 |
# File 'lib/bridgetown-core/concerns/site/localizable.rb', line 20 def locale=(new_locale) I18n.locale = @locale = new_locale.to_sym end |