# File lib/stringex/localization.rb, line 13 def backend @backend ||= i18n_present? ? Backend::I18n : Backend::Internal end
# File lib/stringex/localization.rb, line 17 def backend=(sym_or_class) if sym_or_class.is_a?(Symbol) @backend = case sym_or_class when :internal Backend::Internal when :i18n ensure_i18n! Backend::I18n else raise "Invalid backend :#{sym_or_class}" end else @backend = sym_or_class end end
# File lib/stringex/localization.rb, line 83 def convert(string, options = {}, &block) converter = Converter.new(string, options) converter.instance_exec &block converter.smart_strip! converter.string end
# File lib/stringex/localization.rb, line 61 def default_locale backend.default_locale end
# File lib/stringex/localization.rb, line 65 def default_locale=(new_locale) backend.default_locale = new_locale end
# File lib/stringex/localization.rb, line 53 def locale backend.locale end
# File lib/stringex/localization.rb, line 57 def locale=(new_locale) backend.locale = new_locale end
# File lib/stringex/localization.rb, line 78 def reset! backend.reset! @backend = nil end
# File lib/stringex/localization.rb, line 33 def store_translations(locale, scope, data) backend.store_translations(locale, scope, data) end
# File lib/stringex/localization.rb, line 37 def translate(scope, key, options = {}) return if key == "." # I18n doesn't support dots as translation keys so we don't either locale = options[:locale] || self.locale translation = initial_translation(scope, key, locale) return translation unless translation.nil? if locale != default_locale translate scope, key, options.merge(:locale => default_locale) else default_conversion(scope, key) || options[:default] end end
Generated with the Darkfish Rdoc Generator 2.