lib/boty/locale.rb in boty-0.1.0 vs lib/boty/locale.rb in boty-0.1.1
- old
+ new
@@ -1,24 +1,23 @@
module Boty
class Locale
- def self.reload(locale = nil)
- _locale = new
- I18n.load_path = _locale.locales_paths.uniq
+ def self.reload(language = nil)
+ locale = new
+ I18n.load_path = locale.locales_paths.uniq
I18n.available_locales = I18n::Backend::Simple.new.available_locales
- _locale.set_locale locale if locale
+ locale.locale = language if language
end
def locales_paths
- default_locales_path = File.expand_path("../../../locale/**/*.yml", __FILE__)
- (Dir["locale/**/*.yml"] + Dir[default_locales_path]).
- map { |file| File.expand_path file }
+ locale_yaml_files_path = "../../../locale/**/*.yml"
+ default_locales_path = File.expand_path(locale_yaml_files_path, __FILE__)
+ (Dir["locale/**/*.yml"] + Dir[default_locales_path])
+ .map { |file| File.expand_path file }
end
- def set_locale(locale)
- begin
- I18n.locale = locale
- rescue I18n::InvalidLocale
- I18n.locale = :en
- end
+ def locale=(language)
+ I18n.locale = language
+ rescue I18n::InvalidLocale
+ I18n.locale = :en
end
end
end