module Bridgetown::Site::Localizable

Public Instance Methods

locale() click to toggle source

Returns the current and/or default configured locale @return String

# 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") + "/*.yml"]
    I18n.available_locales = config[:available_locales]
    I18n.default_locale = locale
  end
end
locale=(new_locale) click to toggle source

Sets the current locale for the site @param new_locale [String] for example: “en” for English, “es” for Spanish

# File lib/bridgetown-core/concerns/site/localizable.rb, line 18
def locale=(new_locale)
  I18n.locale = @locale = new_locale.to_sym
end