I2 Localization allows accessing the translations from scripts by calling


string text1 = I2.Loc.ScriptLocalization.Get("Tutorial/MyKEY");


However this could lead to typos or wrong names that are really hard to track. For instance, you could accidentally be asking for ("Tutorial/MyKEy", or "Tutoria/MyKEY") which will fail.


To help write safer scripts, the plugin allows avoiding typing the name of the term your self and instead, a script can be generated with properties that do the access for you.



Just open the Tools Tab and then select the Script Tool.

Then select the terms you are going to access from your code and click Bake.


That will generate a class similar to this one:


public static class ScriptLocalization

{

       public static string Get( string Term ) { ... some code.... }


       public static string MyKey { get{ return Get ("MyKey"); } }


       public static class Tutorial

       {

               public static string MyKey { get{ return Get ("Tutorial/MyKey"); } }

       }

}


which allows accessing the generated properties and they in turn request the translations using the correct string. This way, there is no way to add Typos or wrong string without having the compiler warning you about it.



string text1 = I2.Loc.ScriptLocalization.MyKEY;                      // instead of I2.Loc.ScriptLocalization("MyKEY")

string text2 = I2.Loc.ScriptLocalization.Tutorial.MyKEY;          // instead of I2.Loc.ScriptLocalization("Tutorial/MyKEY")

string text2 = I2.Loc.ScriptLocalization.Tutorial.Tips.MyKEY;



Created with the Personal Edition of HelpNDoc: Full-featured Help generator