ModraUp Ruby API Documentation Ruby API Reference

Class: LanguageHandler

Inherits:
Object
  • Object
show all

Overview

Language string table. Implemented in app/resources/Tools/modraup_langhandler.rb, where langhandler.rb is the compatibility entry point and is required when the host starts. It reads the .strings file by locale; if the file or entry is missing, #GetString / #[] falls back to the key.

Examples:

lh = LanguageHandler.new("plugin.strings")
lh["Open"]

Class Method Summary # collapse

Instance Method Summary # collapse

Class Method Details

LanguageHandler.new(strings_file) ⇒ LanguageHandler

Parameters:

  • strings_file (String)

Returns:

  • (LanguageHandler)

Raises:

  • [ArgumentError] If strings_file is not a String

Examples:

LanguageHandler.new("en.strings")

Instance Method Details

handler.GetString(key) ⇒ String

Return the key itself (copy) when the table or key is missing.

Parameters:

  • key (String)

Returns:

  • (String)

Examples:

LanguageHandler.new("dummy").GetString("Save")  #=> "Save"

handler[key] ⇒ String

Alias for #GetString.

Parameters:

  • key (String)

Returns:

  • (String)

Examples:

LanguageHandler.new("dummy")["Save"]  #=> "Save"

handler.GetStrings ⇒ Hash

The loaded translation table. Returns an empty Hash when .strings is missing; defaults to returning the key when a key is missing.

Returns:

  • (Hash)

Examples:

LanguageHandler.new("dummy").GetStrings