Module: Belorussian
- Extended by:
- Belorussian
- Included in:
- Belorussian
- Defined in:
- lib/belorussian.rb,
lib/belorussian/version.rb,
lib/belorussian/transliteration.rb
Defined Under Namespace
Modules: Transliteration, VERSION
Constant Summary collapse
- LOCALE =
Belorussian locale
:'by'
- LOCALIZE_ABBR_MONTH_NAMES_MATCH =
Regexp machers for context-based belorussian month names and day names translation
/(%[-\d]?d|%e)(.*)(%b)/
- LOCALIZE_MONTH_NAMES_MATCH =
/(%[-\d]?d|%e)(.*)(%B)/
- LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH =
/^%a/
- LOCALIZE_STANDALONE_DAY_NAMES_MATCH =
/^%A/
Instance Method Summary collapse
-
#init_i18n ⇒ Object
Init Belorussian i18n: load all translations shipped with library.
-
#locale ⇒ Object
Belorussian 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 Belorussian localization.
-
#translate(key, options = {}) ⇒ Object
(also: #t)
See I18n::translate.
-
#transliterate(str) ⇒ Object
(also: #translit)
Transliteration for belorussian language.
Instance Method Details
#init_i18n ⇒ Object
Init Belorussian i18n: load all translations shipped with library.
30 31 32 33 34 35 36 37 |
# File 'lib/belorussian.rb', line 30 def init_i18n I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) I18n::Backend::Simple.send(:include, I18n::Backend::Transliterator) I18n.load_path.unshift(*locale_files) I18n.reload! end |
#locale ⇒ Object
Belorussian locale
19 20 21 |
# File 'lib/belorussian.rb', line 19 def locale LOCALE end |
#localize(object, options = {}) ⇒ Object Also known as: l
See I18n::localize
46 47 48 |
# File 'lib/belorussian.rb', line 46 def localize(object, = {}) I18n.localize(object, .merge({ :locale => LOCALE })) end |
#pluralize(n, *variants) ⇒ Object Also known as: p
Simple pluralization proxy
Usage:
Belorussian.pluralize(1, "вещь", "вещи", "вещей")
Belorussian.pluralize(3.14, "вещь", "вещи", "вещей", "вещи")
61 62 63 64 65 66 67 |
# File 'lib/belorussian.rb', line 61 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 Belorussian localization
52 53 54 |
# File 'lib/belorussian.rb', line 52 def strftime(object, format = :default) localize(object, { :format => format }) end |
#translate(key, options = {}) ⇒ Object Also known as: t
See I18n::translate
40 41 42 |
# File 'lib/belorussian.rb', line 40 def translate(key, = {}) I18n.translate(key, .merge({ :locale => LOCALE })) end |
#transliterate(str) ⇒ Object Also known as: translit
Transliteration for belorussian language
Usage:
Belorussian.translit("рубин")
Belorussian.transliterate("рубин")
75 76 77 |
# File 'lib/belorussian.rb', line 75 def transliterate(str) Belorussian::Transliteration.transliterate(str) end |