module

CrystalI18n

Namespace for logic relating to the crystal-i18n format.

This is a reimplementation of the crystal-i18n format from the following projects:

and any of the other similar implementations the community has made.

Note that this is still experimental, mainly in regards to plural-forms. Other than that, it should be fully usable and accurate.

Class methods

define_rule(locale : String, value : Int32 | Int64 | Float64 -> String)

Set pluralization rules for the given locale

This allows you to overwrite or even define new pluralization rules for whatever locale you desire.

CrystalI18n.define_rule("ar", ->(n : Int32 | Int64 | Float64) {
  case
  when n == 0             then "zero"
  when n == 1             then "one"
  when n == 2             then "two"
  when 3..10 === n % 100  then "few"
  when 11..99 === n % 100 then "many"
  else                         "other"
  end
})
Source
plural_rules

Returns all defined CLDR plural rules

Source

Nested types