I18n
Constants
Class methods
An array of all available locales. Must be set explicitly.
I18n.available_locales = %w(en es)
An array of all available locales. Must be set explicitly.
I18n.available_locales = %w(en es)
A current Backend used by I18n. Can be changed in a runtime.
Default locale picked when no locale is passed to #translate.
Defaults to "en".
Default locale picked when no locale is passed to #translate.
Defaults to "en".
Current locale. The next and ongoing translations will be made with this locale, if not passed explicitly.
I18n.locale = "es"
I18n.t("apples", count: 3) # => "3 manzanas"
Current locale. The next and ongoing translations will be made with this locale, if not passed explicitly.
I18n.locale = "es"
I18n.t("apples", count: 3) # => "3 manzanas"
Whether to rescue Backend::TranslationNotFoundError when a translation is missing (defaults to true).
I18n.translate("unknown.key") # => "MISSING: en.unknown.key"
Whether to rescue Backend::TranslationNotFoundError when a translation is missing (defaults to true).
I18n.translate("unknown.key") # => "MISSING: en.unknown.key"
Instance methods
Translates a value in a locale found by keys. Can pass count value to translate in plural form.
If locale not given, uses #locale or #default_locale.
I18n.translate(["hello", "world"]) # => "Hello world!"
I18n.translate(["apples"], "es", count: 3) # => "3 manzanas"
A convenient overloader, keys are passed as a String with dot delimeters.
I18n.translate("hello.world") # => "Hello world!"
I18n.translate("apples", "es", count: 3) # => "3 manzanas"