module Boty class Locale 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 def locales_paths 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 locale=(language) I18n.locale = language rescue I18n::InvalidLocale I18n.locale = :en end end end