class

PointClickEngine::Localization::LocalizationManager

Inherits YAML::Serializable < Reference < Object

Manages translations and localization

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(current_locale : Locale = Locale::En_US, fallback_locale : Locale = Locale::En_US)
Source
new(event_bus : Core::Events::EventBus, current_locale : Locale = Locale::En_US, fallback_locale : Locale = Locale::En_US)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

add_plural_translation(key : String, locale : Locale, forms : Hash(String, String))

Add plural forms programmatically

Source
add_translation(key : String, locale : Locale, value : String)

Add a single translation programmatically

Source
available_locales

Get available locales

Source
clear

Clear all translations

Source
current_locale
Source
current_locale=(current_locale : Locale)
Source
event_bus
Source
event_bus=(event_bus : Core::Events::EventBus | Nil)
Source
fallback_locale
Source
fallback_locale=(fallback_locale : Locale)
Source
load_from_directory(dir : String)

Load translations from a directory (one file per locale)

Source
load_from_file(path : String)

Load translations from YAML file

Source
locale_available?(locale : Locale) : Bool

Check if a locale is available

Source
set_locale(locale : Locale)

Set current locale

Source
t(key : String, count : Int32 | Nil = nil, **params) : String

Convenience alias

Source
translate(key : String, count : Int32 | Nil = nil, **params) : String

Get translated string

Source
translations
Source
translations=(translations : Hash(String, Translation))
Source