module Boty class Locale def self.reload(locale = 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 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 } end def set_locale(locale) begin I18n.locale = locale rescue I18n::InvalidLocale I18n.locale = :en end end end end