class StallmanBot::Locale
Public Class Methods
load_i18n(locale)
click to toggle source
# File lib/stallman_bot/locale.rb, line 5 def self.load_i18n(locale) config = File.expand_path('../../config/locales', File.dirname(__FILE__)) I18n.load_path = Dir["#{config}/*.yml"] begin I18n.locale = locale rescue I18n::InvalidLocale puts "Locale '#{locale}' couldn't be found. Using default 'en'." I18n.locale = I18n.default_locale end end
replies()
click to toggle source
# File lib/stallman_bot/locale.rb, line 22 def self.replies I18n.t(:reply, locale: I18n.default_locale).keys.map(&:to_s) rescue NoMethodError I18n.t(:reply, locale: I18n.default_locale, default: missing('reply')) end
t(s)
click to toggle source
# File lib/stallman_bot/locale.rb, line 16 def self.t(s) I18n.t(s, raise: I18n::MissingTranslationData) rescue I18n::MissingTranslationData I18n.t(s, locale: I18n.default_locale, default: missing(s)) end
Private Class Methods
missing(s)
click to toggle source
# File lib/stallman_bot/locale.rb, line 28 def self.missing(s) "Missing translation '#{s}' in locale." end