Module: Russian
- Extended by:
- Russian
- Included in:
- Russian
- Defined in:
- lib/russian.rb,
lib/russian/transliteration.rb
Defined Under Namespace
Modules: Transliteration, VERSION
Constant Summary collapse
- LOCALE =
Russian locale
:'ru'
Instance Method Summary collapse
-
#i18n_backend_class ⇒ Object
Returns custom backend class for usage with Russian library.
-
#init_i18n ⇒ Object
Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations shipped with library.
-
#locale ⇒ Object
Russian locale.
-
#localize(object, options = {}) ⇒ Object
(also: #l)
See I18n::localize.
-
#pluralize(n, *variants) ⇒ Object
(also: #p)
Simple pluralization proxy.
-
#strftime(object, format = :default) ⇒ Object
strftime() proxy with Russian localization.
-
#translate(key, options = {}) ⇒ Object
(also: #t)
See I18n::translate.
-
#transliterate(str) ⇒ Object
(also: #translit)
Transliteration for russian language.
Instance Method Details
#i18n_backend_class ⇒ Object
Returns custom backend class for usage with Russian library
See I18n::Backend
47 48 49 |
# File 'lib/russian.rb', line 47 def i18n_backend_class I18n::Backend::Advanced end |
#init_i18n ⇒ Object
Init Russian i18n: set custom backend, set default locale to Russian locale, load all translations shipped with library.
53 54 55 56 57 |
# File 'lib/russian.rb', line 53 def init_i18n I18n.backend = Russian.i18n_backend_class.new I18n.default_locale = LOCALE I18n.load_path.unshift(*locale_files) end |
#localize(object, options = {}) ⇒ Object Also known as: l
See I18n::localize
66 67 68 |
# File 'lib/russian.rb', line 66 def localize(object, = {}) I18n.localize(object, .merge({ :locale => LOCALE })) end |
#pluralize(n, *variants) ⇒ Object Also known as: p
81 82 83 84 85 86 87 |
# File 'lib/russian.rb', line 81 def pluralize(n, *variants) raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric) raise ArgumentError, "Must have at least 3 variants for pluralization" if variants.size < 3 raise ArgumentError, "Must have at least 4 variants for pluralization" if (variants.size < 4 && n != n.round) variants_hash = pluralization_variants_to_hash(*variants) I18n.backend.send(:pluralize, LOCALE, variants_hash, n) end |
#strftime(object, format = :default) ⇒ Object
strftime() proxy with Russian localization
72 73 74 |
# File 'lib/russian.rb', line 72 def strftime(object, format = :default) localize(object, { :format => format }) end |
#translate(key, options = {}) ⇒ Object Also known as: t
See I18n::translate
60 61 62 |
# File 'lib/russian.rb', line 60 def translate(key, = {}) I18n.translate(key, .merge({ :locale => LOCALE })) end |
#transliterate(str) ⇒ Object Also known as: translit
95 96 97 |
# File 'lib/russian.rb', line 95 def transliterate(str) Russian::Transliteration.transliterate(str) end |