Drag[en]gine Script Module DragonScript
1.23
|
Manage language translator and language packs. More...
Public Member Functions | |
void | add (LanguagePack languagePack) |
Add language pack. More... | |
void | addFromDirectory (String directory, bool recursive) |
Scan directory for language pack files loading and adding them. More... | |
void | addFromDirectory (String directory, String pattern, bool recursive) |
Scan directory for language pack files loading and adding them. More... | |
Array | allSorted () |
Array with all languages sorted alphabetically by name. More... | |
void | forEach (Block ablock) |
Visit language packs with block with parameter LanguagePack. More... | |
int | getCount () |
Number of language packs. More... | |
LanguagePack | getFallback () |
Fallback language pack. More... | |
LanguagePack | getNamed (UnicodeString name) |
Named language pack or null if absent. More... | |
Array | getNames () |
Get array of language pack names as array of UnicodeString. More... | |
UnicodeString | getTextNoLanguagePack () |
Missing language pack translation. More... | |
TranslationManager | new () |
Create translation manager. More... | |
TranslationManager | new (TranslationManager manager) |
Create copy of translation manager. More... | |
void | removeAll () |
Remove all language packs. More... | |
void | setActiveNamed (UnicodeString name) |
Set active language pack by name. More... | |
void | setActiveNamedIfPresent (UnicodeString name) |
Set active language pack by name if present. More... | |
void | setActiveWithId (String identifier) |
Set active language pack by identifier. More... | |
void | setActiveWithIdIfPresent (String identifier) |
Set active language pack by identifier if present. More... | |
void | setFallback (LanguagePack languagePack) |
Set fallback language pack. More... | |
void | setFallbackWithId (String identifier) |
Set fallback language pack by identifier. More... | |
void | setFallbackWithIdIfPresent (String identifier) |
Set fallback language pack by identifier if present. More... | |
void | setTextNoLanguagePack (UnicodeString text) |
Set missing language pack translation. More... | |
UnicodeString | translate (String name) |
Translation for entry name or missing text if absent. More... | |
UnicodeString | translate (String name, UnicodeString defaultValue) |
Translation for entry name or default value if absent. More... | |
UnicodeString | translateIf (UnicodeString text, int marker) |
Translate text if it starts with a translation character. More... | |
UnicodeString | translateIf (UnicodeString text, int marker, UnicodeString defaultValue) |
Translate text if it starts with a translation character. More... | |
Static Public Member Functions | |
static TranslationManager | get () |
Get TranslationManager from BaseGameApp. More... | |
Public Attributes | |
LanguagePack | pActiveLanguagePack |
LanguagePack | pFallbackLanguagePack |
Dictionary | pLanguagePacks |
UnicodeString | pTextNoLanguagePack |
Manage language translator and language packs.
Provides support to load language packs into memory and seleting one of them to translate texts with. Upon switching the active language pack users have to call the translation methods again to obtain the new text.
void Dragengine.Utils.TranslationManager.add | ( | LanguagePack | languagePack | ) |
Add language pack.
void Dragengine.Utils.TranslationManager.addFromDirectory | ( | String | directory, |
bool | recursive | ||
) |
Scan directory for language pack files loading and adding them.
After calling this method call setActiveLanguagePack to choose one of the loaded language packs to use.
directory | Absolute path to directory to scan for files. |
recursive | If true scans also in all child directories. |
void Dragengine.Utils.TranslationManager.addFromDirectory | ( | String | directory, |
String | pattern, | ||
bool | recursive | ||
) |
Scan directory for language pack files loading and adding them.
After calling this method call setActiveLanguagePack to choose one of the loaded language packs to use.
directory | Absolute path to directory to scan for files. |
pattern | File pattern to match. Has to be of the form "*.extension" |
recursive | If true scans also in all child directories. |
Array Dragengine.Utils.TranslationManager.allSorted | ( | ) |
Array with all languages sorted alphabetically by name.
void Dragengine.Utils.TranslationManager.forEach | ( | Block | ablock | ) |
Visit language packs with block with parameter LanguagePack.
|
static |
Get TranslationManager from BaseGameApp.
Convenience method for BaseGameApp.getApp().getTranslationManager() .
int Dragengine.Utils.TranslationManager.getCount | ( | ) |
Number of language packs.
LanguagePack Dragengine.Utils.TranslationManager.getFallback | ( | ) |
Fallback language pack.
LanguagePack Dragengine.Utils.TranslationManager.getNamed | ( | UnicodeString | name | ) |
Named language pack or null if absent.
Array Dragengine.Utils.TranslationManager.getNames | ( | ) |
Get array of language pack names as array of UnicodeString.
UnicodeString Dragengine.Utils.TranslationManager.getTextNoLanguagePack | ( | ) |
Missing language pack translation.
TranslationManager Dragengine.Utils.TranslationManager.new | ( | ) |
Create translation manager.
TranslationManager Dragengine.Utils.TranslationManager.new | ( | TranslationManager | manager | ) |
Create copy of translation manager.
void Dragengine.Utils.TranslationManager.removeAll | ( | ) |
Remove all language packs.
void Dragengine.Utils.TranslationManager.setActiveNamed | ( | UnicodeString | name | ) |
Set active language pack by name.
void Dragengine.Utils.TranslationManager.setActiveNamedIfPresent | ( | UnicodeString | name | ) |
Set active language pack by name if present.
void Dragengine.Utils.TranslationManager.setActiveWithId | ( | String | identifier | ) |
Set active language pack by identifier.
void Dragengine.Utils.TranslationManager.setActiveWithIdIfPresent | ( | String | identifier | ) |
Set active language pack by identifier if present.
void Dragengine.Utils.TranslationManager.setFallback | ( | LanguagePack | languagePack | ) |
Set fallback language pack.
void Dragengine.Utils.TranslationManager.setFallbackWithId | ( | String | identifier | ) |
Set fallback language pack by identifier.
void Dragengine.Utils.TranslationManager.setFallbackWithIdIfPresent | ( | String | identifier | ) |
Set fallback language pack by identifier if present.
void Dragengine.Utils.TranslationManager.setTextNoLanguagePack | ( | UnicodeString | text | ) |
Set missing language pack translation.
UnicodeString Dragengine.Utils.TranslationManager.translate | ( | String | name | ) |
Translation for entry name or missing text if absent.
UnicodeString Dragengine.Utils.TranslationManager.translate | ( | String | name, |
UnicodeString | defaultValue | ||
) |
Translation for entry name or default value if absent.
UnicodeString Dragengine.Utils.TranslationManager.translateIf | ( | UnicodeString | text, |
int | marker | ||
) |
Translate text if it starts with a translation character.
This call can be used for plain text and text prefixed with a marker character. If text is empty or the first character in text does not match the translation character the text is returned unmodified. Otherwise the entire text after the translation character converted to UTF-8 encoding is used as name in a call to translate(String).
Choose the marker character to not be found at the start of any text you can possibly encounter. A typical choice is '@'.
UnicodeString Dragengine.Utils.TranslationManager.translateIf | ( | UnicodeString | text, |
int | marker, | ||
UnicodeString | defaultValue | ||
) |
Translate text if it starts with a translation character.
This call can be used for plain text and text prefixed with a marker character. If text is empty or the first character in text does not match the translation character the text is returned unmodified. Otherwise the entire text after the translation character converted to UTF-8 encoding is used as name in a call to translate(String, UnicodeString).
Choose the marker character to not be found at the start of any text you can possibly encounter. A typical choice is '@'.
LanguagePack Dragengine.Utils.TranslationManager.pActiveLanguagePack |
LanguagePack Dragengine.Utils.TranslationManager.pFallbackLanguagePack |
Dictionary Dragengine.Utils.TranslationManager.pLanguagePacks |
UnicodeString Dragengine.Utils.TranslationManager.pTextNoLanguagePack |