Class: AMS::Translate
- Inherits:
-
Object
- Object
- AMS::Translate
- Defined in:
- ext-ruby/ams_lib/translate.rb
Overview
The translation module was changed in 3.7.0 from the strings format to JSON
Compatible with SU2014 or later
Translate allows loading and controlling localization of strings.
Instance Attribute Summary collapse
- #strings ⇒ Object readonly
Instance Method Summary collapse
-
#convert_text(t1) ⇒ String
Convert text.
- #get(k) ⇒ Object (also: #[])
-
#initialize(dir, toolname, locale = nil) ⇒ Translate
constructor
Load JSON translation strings.
-
#sprintf(k, *args) ⇒ String
Translate and format a string.
Constructor Details
#initialize(dir, toolname, locale = nil) ⇒ Translate
The extension of a translation file must end with .json. Toolname and locale must be separated with an underscore. Example: commands_ru.json or commands_pt-BR.json. File names are not case sensitive.
The commands within a translate file must following the "base language str": "locale language str" syntax.
No errors will be raised if a translation file is invalid.
Load JSON translation strings.
Instance Attribute Details
#strings ⇒ Object (readonly)
Instance Method Details
#convert_text(t1) ⇒ String
Convert text. Items enclosed in TR
and double brackets are translated:
TR{{my text}}
#get(k) ⇒ Object Also known as: []
#sprintf(k, *args) ⇒ String
Translate and format a string