Search the Community
Showing results for tags 'localization'.
EDIT: Turns out the code is incompatible with AUTO_TRA. Until future investigation, you can't use this if you are not wiling to resign from using AUTO_TRA function. EDIT: Guide was updated to reflect proper and supported usage along with AUTO_TRA. Introduction: Since introduction of HANDLE_CHARSETS, modders have given the ability to support translation for both classic and enhanced editions of the Infinity Engine games. The function itself was doing it's job: convert file encoding from one to another. But it also had annoyances which various modders was able to overcome via custom code. Now, with the introduction of `out_path` parameter, all of the annoyances are gone. This is an attempt to show how to get the best out of HANDLE_CHARSETS. How it was handled before: translators provide .tra files using their own preferred local encoding HANDLE_CHARSETS function convert those files into UTF8 encoding when mod was installed on enhanced game editions How it is handled now: translators provide .tra files using UTF8 encoding when the mod is installed on classic game editions, the temporary copy of translation files are converted into ASCII encoding so the source files are not touched no modification of original UTF8-files when mod is installed on enhanced game editions Using new way will save you from annoyances and allow for new features: DOS/Shell console messages can finally have localized characters displayed properly modders no longer need to watch-out to not break custom encoding when editing foreign tra files modders can receive translations via forum posts and it can be used instantly, without hustle translators no longer send files just to update one single line translation can be provided by editing files directly via GitHub online interface Prerequisites: required minimum version of WeiDU is 247 WeiDU executable must be 64-bit for DOS/Shell console messages being able to display localized characters properly Full code example: https://github.com/ALIENQuake/WeiDU-UTF8 Code explanation: BACKUP "weidu_external\backup\WeiDU-UTF8-Example" // move backup folder outside of the main mod data folder Move backup folder outside of the main mod data folder. The %MOD_FOLDER% is read from this value but we will change it later to the correct mod data directory. ACTION_DEFINE_ARRAY arrayNoConvert BEGIN setup END ACTION_DEFINE_ARRAY arrayReload BEGIN mod END Define two arrays for `noconvert_array` and `reload_array` parameters of `HANDLE_CHARSETS` function because those parameters require array. You cannot provide the filenames directly. The .tra file extension is optional. LAF HANDLE_CHARSETS INT_VAR from_utf8 = 1 //the source tra files of all languages are UTF8 infer_charset = 1 //set the correct encoding for classic games based on the detected game and associated encoding verbose = 1 //display more debugging info Parameter from_utf8 = 1will tell WeiDU that the source tra files of all languages are UTF8. The infer_charset = 1 will set the correct encoding for classic games based on the detected game and associated encoding. The verbose = 1 will display more debugging info. tra_path = "%MOD_FOLDER%\lang" // path to translation files, do not add slash at the end of it Path to translation files, do not add slash at the end of it. out_path = "weidu_external\lang\%MOD_FOLDER%" // path to temporary work directory, do not add slash at the end of it This is very important. WeiDU documentation says: "Note that if %tra_path and out_path are the same directory, the conversion will naturally happen only once regardless of how many times HANDLE_CHARSETS are invoked, but if the directories are different, the conversion will happen for every invocation (notably, if HANDLE_CHARSETS is invoked among the ALWAYS actions)." So when WeiDU preforming conversion operation, it overwrite original mod files and it can also change their encoding if the mod was installed on the classic editions of the games. So in order to keep original files intact, we need to provide two different path for `out_path` and `tra_path` parameters. Since WeiDU doesn't have concept of 'temporary work directory' we need to create it manually earlier. Also, AUTO_TRA must use this directory as part of the path: AUTO_TRA "weidu_external\lang\%MOD_FOLDER%\%s" //use out_path + \%s In order for this solution to be compatible with AUTO_TRA, you have to use the 'conversion output" path so classic games will always load converted files. OUTER_SPRINT MOD_FOLDER "WeiDU-UTF8-Example" MKDIR "weidu_external\lang\%MOD_FOLDER%" Create 'temporary work directory'. Additionally, we are make sure that %MOD_FOLDER% variable have proper value for mod data directory. // Don't use %MOD_FOLDER% for LANGUAGE until it will be fixed, http://forums.pocketplane.net/index.php?topic=29521 LANGUAGE "English" "english" "WeiDU-UTF8-Example\lang\english\setup.tra" LANGUAGE "Czech" "czech" "WeiDU-UTF8-Example\lang\czech\setup.tra" LANGUAGE "French" "french" "WeiDU-UTF8-Example\lang\french\setup.tra" LANGUAGE "German" "german" "WeiDU-UTF8-Example\lang\german\setup.tra" LANGUAGE "Italian" "italian" "WeiDU-UTF8-Example\lang\italian\setup.tra" LANGUAGE "Russian" "russian" "WeiDU-UTF8-Example\lang\russian\setup.tra" LANGUAGE "Polish" "polish" "WeiDU-UTF8-Example\lang\polish\setup.tra" LANGUAGE "Spanish" "spanish" "WeiDU-UTF8-Example\lang\spanish\setup.tra" Don't use %MOD_FOLDER% for LANGUAGE until it will be fixed, http://forums.pocketplane.net/index.php?topic=29521 The rest of the mod code should be self-explanatory. If not, please refer to WeiDU Documentation or ask here.