mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
localization utiity methods
to better adress https://github.com/TorqueGameEngines/Torque3D/issues/1036
This commit is contained in:
parent
cf233367a8
commit
5e6a95866a
2 changed files with 38 additions and 1 deletions
|
|
@ -130,3 +130,33 @@ function getButtonBitmap(%device, %button)
|
|||
|
||||
return %assetId;
|
||||
}
|
||||
|
||||
function createLangTable(%name)
|
||||
{
|
||||
// create a langtable, and global variable to be referenced by GUI elements
|
||||
// opeates as follows:
|
||||
// root gui element contains langTableMod = mylang;
|
||||
// subelements inherit or override
|
||||
// langTableMod then informs the underlying system to look for a $I18N::mylang
|
||||
// this holds a reference to a table defined in .lso files, using data/UI/langs/languageMap global defines as a key
|
||||
new LangTable(%name){};
|
||||
eval("$I18N::"@ %name @"="@ %name @".getId();");
|
||||
}
|
||||
|
||||
function addLanguage(%langTable, %filename, %alias)
|
||||
{
|
||||
// generate an .lso file and if a languageMap file does not exist, it as well
|
||||
%needLangMap = true;
|
||||
if(isFile("data/UI/langs/languageMap"))
|
||||
%needLangMap = false;
|
||||
|
||||
CompileLanguage("data/UI/langs/"@ %filename @".txt", %needLangMap);
|
||||
%langTable.addLanguage("data/UI/langs/"@ %filename @".lso", %alias);
|
||||
}
|
||||
|
||||
function switchLanguage(%language) //use here the #n as it's the order of inclusion
|
||||
{
|
||||
// swap existing language from the current core langtable and refresh the gui contents
|
||||
getCoreLangTable().setCurrentLanguage(%language);
|
||||
Canvas.setContent(Canvas.getContent());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue