Module: Polish
Defined Under Namespace
Modules: VERSION
Constant Summary collapse
- LOCALE =
Polish locale
:'pl'
Instance Method Summary collapse
-
#i18n_backend_class ⇒ Object
Returns custom backend class for usage with Polish library.
-
#init_i18n ⇒ Object
Init Polish i18n: set custom backend, load all translations shipped with library.
-
#locale ⇒ Object
Polish 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 Polish localization.
-
#translate(key, options = {}) ⇒ Object
(also: #t)
See I18n::translate.
Instance Method Details
#i18n_backend_class ⇒ Object
Returns custom backend class for usage with Polish library
See I18n::Backend
46 47 48 |
# File 'lib/polish.rb', line 46 def i18n_backend_class I18n::Backend::Advanced end |
#init_i18n ⇒ Object
Init Polish i18n: set custom backend, load all translations shipped with library.
52 53 54 55 |
# File 'lib/polish.rb', line 52 def init_i18n I18n.backend = Polish.i18n_backend_class.new I18n.load_path.unshift(*locale_files) end |
#localize(object, options = {}) ⇒ Object Also known as: l
See I18n::localize
64 65 66 |
# File 'lib/polish.rb', line 64 def localize(object, = {}) I18n.localize(object, .merge({ :locale => LOCALE })) end |
#pluralize(n, *variants) ⇒ Object Also known as: p
78 79 80 81 82 83 |
# File 'lib/polish.rb', line 78 def pluralize(n, *variants) raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric) raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3 variants_hash = pluralization_variants_to_hash(*variants) I18n.backend.send(:pluralize, LOCALE, variants_hash, n) end |
#strftime(object, format = :default) ⇒ Object
strftime() proxy with Polish localization
70 71 72 |
# File 'lib/polish.rb', line 70 def strftime(object, format = :default) localize(object, { :format => format }) end |