|
Drag[en]gine Script Module DragonScript 1.35
|
Manage language translator and language packs. More...
Public Member Functions | |
| void | add (LanguagePack languagePack) |
| Add language pack. | |
| void | addFromDirectory (String directory, bool recursive) |
| Scan directory for language pack files loading and adding them. | |
| void | addFromDirectory (String directory, String pattern, bool recursive) |
| Scan directory for language pack files loading and adding them. | |
| Array | allSorted () |
| Array with all languages sorted alphabetically by name. | |
| void | forEach (Block ablock) |
| Visit language packs with block with parameter LanguagePack. | |
| int | getCount () |
| Number of language packs. | |
| LanguagePack | getFallback () |
| Fallback language pack. | |
| LanguagePack | getNamed (UnicodeString name) |
| Named language pack or null if absent. | |
| Array | getNames () |
| Get array of language pack names as array of UnicodeString. | |
| UnicodeString | getTextNoLanguagePack () |
| Missing language pack translation. | |
| TranslationManager | new () |
| Create translation manager. | |
| TranslationManager | new (TranslationManager manager) |
| Create copy of translation manager. | |
| void | removeAll () |
| Remove all language packs. | |
| void | setActiveNamed (UnicodeString name) |
| Set active language pack by name. | |
| void | setActiveNamedIfPresent (UnicodeString name) |
| Set active language pack by name if present. | |
| void | setActiveWithId (String identifier) |
| Set active language pack by identifier. | |
| void | setActiveWithIdIfPresent (String identifier) |
| Set active language pack by identifier if present. | |
| void | setFallback (LanguagePack languagePack) |
| Set fallback language pack. | |
| void | setFallbackWithId (String identifier) |
| Set fallback language pack by identifier. | |
| void | setFallbackWithIdIfPresent (String identifier) |
| Set fallback language pack by identifier if present. | |
| void | setTextNoLanguagePack (UnicodeString text) |
| Set missing language pack translation. | |
| UnicodeString | translate (String name) |
| Translation for entry name or missing text if absent. | |
| UnicodeString | translate (String name, UnicodeString defaultValue) |
| Translation for entry name or default value if absent. | |
| UnicodeString | translateIf (UnicodeString text, int marker) |
| Translate text if it starts with a translation character. | |
| UnicodeString | translateIf (UnicodeString text, int marker, UnicodeString defaultValue) |
| Translate text if it starts with a translation character. | |
Static Public Member Functions | |
| static TranslationManager | get () |
| Get TranslationManager from BaseGameApp. | |
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.
Referenced by addFromDirectory(), and setFallbackWithIdIfPresent().
| 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. |
References getNames(), pLanguagePacks, and removeAll().
Referenced by addFromDirectory().
| 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. |
References add(), addFromDirectory(), allSorted(), forEach(), getFallback(), getNamed(), pActiveLanguagePack, pFallbackLanguagePack, pLanguagePacks, setActiveNamed(), setActiveNamedIfPresent(), setActiveWithId(), setActiveWithIdIfPresent(), setFallback(), setFallbackWithId(), and setFallbackWithIdIfPresent().
| Array Dragengine.Utils.TranslationManager.allSorted | ( | ) |
Array with all languages sorted alphabetically by name.
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.forEach | ( | Block | ablock | ) |
Visit language packs with block with parameter LanguagePack.
Referenced by addFromDirectory().
|
static |
Get TranslationManager from BaseGameApp.
Convenience method for BehaviorElementClass.sharedFactoryHelper.getTranslationManager() .
| int Dragengine.Utils.TranslationManager.getCount | ( | ) |
Number of language packs.
Referenced by getFallback().
| LanguagePack Dragengine.Utils.TranslationManager.getFallback | ( | ) |
Fallback language pack.
References getCount(), and pLanguagePacks.
Referenced by addFromDirectory().
| LanguagePack Dragengine.Utils.TranslationManager.getNamed | ( | UnicodeString | name | ) |
Named language pack or null if absent.
Referenced by addFromDirectory(), and setFallback().
| Array Dragengine.Utils.TranslationManager.getNames | ( | ) |
Get array of language pack names as array of UnicodeString.
Referenced by addFromDirectory().
| UnicodeString Dragengine.Utils.TranslationManager.getTextNoLanguagePack | ( | ) |
Missing language pack translation.
Referenced by setActiveNamedIfPresent().
| TranslationManager Dragengine.Utils.TranslationManager.new | ( | ) |
Create translation manager.
References new(), pLanguagePacks, and pTextNoLanguagePack.
Referenced by new().
| TranslationManager Dragengine.Utils.TranslationManager.new | ( | TranslationManager | manager | ) |
Create copy of translation manager.
References pActiveLanguagePack, pFallbackLanguagePack, pLanguagePacks, and pTextNoLanguagePack.
| void Dragengine.Utils.TranslationManager.removeAll | ( | ) |
Remove all language packs.
References translate(), and translateIf().
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setActiveNamed | ( | UnicodeString | name | ) |
Set active language pack by name.
References translate(), and translateIf().
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setActiveNamedIfPresent | ( | UnicodeString | name | ) |
Set active language pack by name if present.
References getTextNoLanguagePack(), and pTextNoLanguagePack.
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setActiveWithId | ( | String | identifier | ) |
| void Dragengine.Utils.TranslationManager.setActiveWithIdIfPresent | ( | String | identifier | ) |
Set active language pack by identifier if present.
References pTextNoLanguagePack, and setTextNoLanguagePack().
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setFallback | ( | LanguagePack | languagePack | ) |
Set fallback language pack.
References getNamed(), and pLanguagePacks.
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setFallbackWithId | ( | String | identifier | ) |
| void Dragengine.Utils.TranslationManager.setFallbackWithIdIfPresent | ( | String | identifier | ) |
Set fallback language pack by identifier if present.
References add(), and pLanguagePacks.
Referenced by addFromDirectory().
| void Dragengine.Utils.TranslationManager.setTextNoLanguagePack | ( | UnicodeString | text | ) |
Set missing language pack translation.
Referenced by setActiveWithIdIfPresent().
| UnicodeString Dragengine.Utils.TranslationManager.translate | ( | String | name | ) |
Translation for entry name or missing text if absent.
Referenced by removeAll(), setActiveNamed(), translate(), and translateIf().
| UnicodeString Dragengine.Utils.TranslationManager.translate | ( | String | name, |
| UnicodeString | defaultValue ) |
Translation for entry name or default value if absent.
References pActiveLanguagePack, and translate().
| 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 '@'.
References pActiveLanguagePack, pFallbackLanguagePack, pTextNoLanguagePack, and translate().
Referenced by removeAll(), and setActiveNamed().
| 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 '@'.
References pFallbackLanguagePack.
| LanguagePack Dragengine.Utils.TranslationManager.pActiveLanguagePack |
Referenced by addFromDirectory(), new(), translate(), and translateIf().
| LanguagePack Dragengine.Utils.TranslationManager.pFallbackLanguagePack |
Referenced by addFromDirectory(), new(), translateIf(), and translateIf().
| Dictionary Dragengine.Utils.TranslationManager.pLanguagePacks |
Referenced by addFromDirectory(), addFromDirectory(), getFallback(), new(), new(), setFallback(), and setFallbackWithIdIfPresent().
| UnicodeString Dragengine.Utils.TranslationManager.pTextNoLanguagePack |
Referenced by new(), new(), setActiveNamedIfPresent(), setActiveWithIdIfPresent(), and translateIf().