doudou Posted March 3, 2010 Share Posted March 3, 2010 If you want to move presentation strings from your AutoIt script/application, translate them into different language and transparently load them at run-time accordingly to user's locale settings, this library can be useful.The UDF provides two different ways to store localized resources:Win32 resource files (EXE, DLL)INI filesWin32 resource files (EXE, DLL)Compile your resource strings either into your AU3-EXE or one or more DLL files. You can have all of target languages in a single file, in this case Windows takes care of choosing the appropriate language when your script is executed, or separate them in one DLL per language, the UDF decides then which one to load. The naming convention for DLLs is <MAINSCRIPTNAME>[_<LANGID>].dll, where <MAINSCRIPTNAME> is the name of executed script and <LANGID> is a language identifier from the listed in AutoIt online help (s. @OSLang). The file without <LANGID> suffix is the default and is always loaded.Add this to your script: #include "LocalizationStringTableRES.au3" ; resource IDs matching that in the string table Global Const $IDS_SOMESTRING = 1000 You can now load the localized strings like that: Local $text = _LR_GetString("IDS_SOMESTRING")INI filesSave your resource strings in an INI named <MAINSCRIPTNAME>_StringTable.ini. The sections in the INI separate different languages, the section [0000] is the default, other sections are named as corresponding language identifier (s. @OSLang in AutoIt online help). The INI keys are used as resource IDs. The UDF loads only the section matching user's locale or the default one. Important: resource INI files must have been saved as "Unicode" (Notepad) or "UCS-2 Little Endian" (Scite) for international characters to be handled properly.Add this to your script (constant definitions for resource IDs are not needed): #include "LocalizationStringTableINI.au3" You can now load the localized strings like that: Local $text = _LR_GetString("IDS_SOMESTRING")Both methods have their own advantages and disadvantages, so it is up to you which one to choose. Whatever the choice was, you can switch anytime to the alternative: apart from the used include and resource ID constants needed for binary resources it requires no changes in the program code. The attached examples demonstrate both methods and include simple RES/DLL files which could be used as templates for own binary string tables (edit them with ResHacker for example).au3_localization_v1.0.zipau3_localization_samples_v1.0.zip UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now