class I18n::Backend::Yaml

Defined in:

i18n/backend/yaml.cr

Constant Summary

EMPTY_HASH = {} of String => String

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from class I18n::Backend::Base

available_locales : Array(String) available_locales, load(*args) load, localize(locale : String, object, scope = :number, format = nil) : String localize, translate(locale : String, key : String, opitions : Hash | NamedTuple | Nil, count = nil, default = nil, iter = nil) : String translate

Class Method Detail

def self.normalize(data : YAML::Any, path : String = "", final = Hash(String, YAML::Any).new) #

Flatten paths


[View source]

Instance Method Detail

def available_locales : Array(String) #

[View source]
def load(*args) #

Read files, normalize and merge all the translations


[View source]
def localize(locale : String, object : Number, scope = :number, format = nil) : String #

Localize a number or a currency Use the format if given scope can be one of :number ( default ), :currency

Following keys are required :

__formats__:
      number:
        decimal_separator: ','
      precision_separator: '.'

      currency:
        symbol: '€'
      name: 'euro'
      format: '%s€'

[View source]
def localize(locale : String, object : Time, scope = :time, format = nil) : String #

Localize a date or a datetime using the format if provided. scope can be one of :time ( default ), :date, :datetime

NOTE According to ISO 8601, Monday is the first day of the week

Following keys are required :

__formats__:
      date:
        formats:
        default: "%Y-%m-%d"
      long: "%A, %d of %B %Y"

      month_names: [January, February, March, April, May, June, July, August, September, October, November, December]
      abbr_month_names: [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]

      day_names: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]
      abbr_day_names: [Mon, Tue, Wed, Thu, Fri, Sat, Sun]

      time:
        formats:
            default: "%I:%M:%S %p"

[View source]
def localize(locale : String, object, scope = :number, format = nil) : String #

Invokes #to_s on the object ignoring scope and format


[View source]
def translate(locale : String, key : String, options : Hash | NamedTuple | Nil = EMPTY_HASH, count = nil, default = nil, iter = nil) : String #

[View source]
def translations : Hash(String, Hash(String, YAML::Any)) #

[View source]
def translations=(translations : Hash(String, Hash(String, YAML::Any))) #

[View source]

Macro Detail

macro embed(dirs) #

[View source]