lib/remarkable/i18n.rb in remarkable-3.0.8 vs lib/remarkable/i18n.rb in remarkable-3.0.9
- old
+ new
@@ -1,31 +1,54 @@
-# This is a wrapper for I18n default functionality
-module Remarkable
+module Remarkable
+ # This is a wrapper for I18n default functionality.
+ #
+ # Remarkable shouldn't rely on I18n default locale, because it might change
+ # throughout tests. So it's Remarkable responsibility to hold its own locale
+ # and send it to I18n.
+ #
module I18n
- # Add locale files to I18n and to load path, if it exists.
+ # Add locale files to I18n and to load path, if it exists.
+ #
+ # == Examples
+ #
+ # Remarkable.add_locale "path/to/locale"
+ #
def add_locale(*locales)
::I18n.backend.load_translations *locales
::I18n.load_path += locales if ::I18n.respond_to?(:load_path)
end
- # Set Remarkable locale (which is not necessarily the same as the application)
+ # Set Remarkable own locale.
+ #
+ # == Examples
+ #
+ # Remarkable.locale = :en
+ #
def locale=(locale)
@@locale = locale
end
- # Get Remarkable locale (which is not necessarily the same as the application)
+ # Get Remarkable own locale.
+ #
+ # == Examples
+ #
+ # Remarkable.locale = :en
+ # Remarkable.locale #=> :en
+ #
def locale
@@locale
end
- # Wrapper for translation
+ # Wrapper for I18n.translate
+ #
def translate(string, options = {})
::I18n.translate string, { :locale => @@locale }.merge(options)
end
alias :t :translate
- # Wrapper for localization
+ # Wrapper for I18n.localize
+ #
def localize(object, options = {})
::I18n.localize object, { :locale => @@locale }.merge(options)
end
alias :l :localize