Class: AMS::Translate

Inherits:
Object
  • Object
show all
Defined in:
ext-ruby/ams_lib/translate.rb

Overview

Note:

The translation module was changed in 3.7.0 from the strings format to JSON

Note:

Compatible with SU2014 or later

Translate allows loading and controlling localization of strings.

Since:

  • 3.7.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, toolname, locale = nil) ⇒ Translate

Note:

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.

Note:

The commands within a translate file must following the "base language str": "locale language str" syntax.

Note:

No errors will be raised if a translation file is invalid.

Load JSON translation strings.

Parameters:

  • dir (String)

    Path to the directory with translation files

  • toolname (String)

    Base name of the translation file.

  • locale (String, nil) (defaults to: nil)

    Specific language to look for or nil to relent on current localization.

Since:

  • 3.7.0

Instance Attribute Details

#stringsObject (readonly)

Since:

  • 3.7.0

Instance Method Details

#convert_text(t1) ⇒ String

Convert text. Items enclosed in TR and double brackets are translated: TR{{my text}}

Parameters:

  • t1 (String)

    Text to translate

Returns:

  • (String)

Since:

  • 3.7.0

#get(k) ⇒ Object Also known as: []

Parameters:

  • k (String)

Since:

  • 3.7.0

#sprintf(k, *args) ⇒ String

Translate and format a string

Parameters:

  • k (String)

    Text

  • args (Array<Object>)

    sprintf arguments

Returns:

  • (String)

Since:

  • 3.7.0