Class: Boty::Locale
- Inherits:
-
Object
- Object
- Boty::Locale
- Defined in:
- lib/boty/locale.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reload(language = nil) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/boty/locale.rb', line 3 def self.reload(language = nil) locale = new I18n.load_path = locale.locales_paths.uniq I18n.available_locales = I18n::Backend::Simple.new.available_locales locale.locale = language if language end |
Instance Method Details
#locale=(language) ⇒ Object
17 18 19 20 21 |
# File 'lib/boty/locale.rb', line 17 def locale=(language) I18n.locale = language rescue I18n::InvalidLocale I18n.locale = :en end |
#locales_paths ⇒ Object
10 11 12 13 14 15 |
# File 'lib/boty/locale.rb', line 10 def locales_paths locale_yaml_files_path = "../../../locale/**/*.yml" default_locales_path = File.(locale_yaml_files_path, __FILE__) (Dir["locale/**/*.yml"] + Dir[default_locales_path]) .map { |file| File. file } end |