subtledoctor Posted November 13, 2016 Author Share Posted November 13, 2016 Okay, next (final?) step is to figure out how to detect the user's game language. Does Weidu have an automated way to find this out? I know Weidu asks you to choose which language to install in, but I'm in the situation where the mod only has English and Polish translations, and maybe someone with their game in Italian wants to use the mod. They might simply install the English version of the mod into their Italian game. (Especially for the Armor System component, most of the changes are purely functional.) But, even though they chose "English" when running Weidu, I want to component to see and use the Italian translation for those three terms. Ideally, without any further intervention. Basically, I'll have something like: [find language of BG game] OUTER_SPRINT the_lang [the game language] WITH_TRA ~%the_lang%/YARAS.tra~ BEGIN OUTER_SPRINT dragon_tra @10 // ~dragon~ END COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN READ_SHORT 0x1c type PATCH_IF (type = 2) BEGIN READ_LONG 0x0c id_name_strref PATCH_IF (id_name_strref >= 0 && id_name_strref < 2147483646) BEGIN READ_STRREF 0x0c ~id_name~ PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+1~) BEGIN WRITE_LONG 0x60 1 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+2~) BEGIN WRITE_LONG 0x60 2 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+3~) BEGIN WRITE_LONG 0x60 3 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+4~) BEGIN WRITE_LONG 0x60 4 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+5~) BEGIN WRITE_LONG 0x60 5 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~+6~) BEGIN WRITE_LONG 0x60 6 END PATCH_IF NOT (~%id_name%~ STRING_CONTAINS_REGEXP ~%dragon_tra%~) BEGIN WRITE_LONG 0x60 4 END END END END BUT_ONLY Ideas? Link to comment
agb1 Posted November 13, 2016 Share Posted November 13, 2016 Again according to WeiDU doc, EE_LANGUAGE evaluates to the Enhanced Edition language directory the user has selected, for example, en_US. This variable is undefined on non-EE games. Link to comment
subtledoctor Posted November 19, 2016 Author Share Posted November 19, 2016 The following lines are from the various BG:EE dialog.tlk files: EN: Armor Class Dragon Elven CH: 防御等级 龙 精灵 (not certain if it matches more than Elven Chain Mail) CS: Obranné číslo Dračí / Drak Elfí DE: Rüstungsklasse Drache Elfen ES: Clase de armadura Dragón / Dragon élfica JP: アーマークラス ドラゴン / 竜 エルフ KO: 방어도 드래곤 엘프제 RU: Класс защиты дракон (plus various suffixes) Эльфийск (plus various suffixes) Very handy - assuming I can copy and paste all of that into separate little .tra files. Final piece of the puzzle: the EE games have the %EE_LANGUAGE% variable, but BGT games don't. I can read the user's .ini file and find this: language=english language25=englishEasy enough to read that and match a variable to the EE one, then to use as a patch to the WITH_TRA tra files. But to match them, I need to know all of the possible values for that line of the .ini file. can anyone think of a way to find that out? If anyone plays on the old engine in non-English languages, could you mention how that line of your .ini reads? Much thanks as always! Link to comment
argent77 Posted November 19, 2016 Share Posted November 19, 2016 Final piece of the puzzle: the EE games have the %EE_LANGUAGE% variable, but BGT games don't. I can read the user's .ini file and find this: language=english language25=englishEasy enough to read that and match a variable to the EE one, then to use as a patch to the WITH_TRA tra files. But to match them, I need to know all of the possible values for that line of the .ini file. can anyone think of a way to find that out? If anyone plays on the old engine in non-English languages, could you mention how that line of your .ini reads? I wouldn't be so sure. These lines are more likely representing the locale settings of the operating system at install time which don't necessarily match the game language. You could try to analyze specific vanilla game strrefs to determine the game language, but even this isn't foolproof in a heavily modded game. Or ask the user about the game language. Link to comment
subtledoctor Posted November 19, 2016 Author Share Posted November 19, 2016 Hmm. This is a really annoying problem. Maybe I can reverse the regexp lookup for those lines. Find the dragon strref, do a IF STRING_CONTAINS_REGEXP for each language's version of "dragon," set the successful one as the language, then plug that language into the WITH_TRA definition, the do the "forwards" STRING_CONTAINS_REGEXP on the armor item name inside the WITH_TRA clause. Or just make the component EE-only. This is just yet another instance (in a long line of instances) of the EEs making things far easier for the modder. Heck, most of the players holding out using the old engine only use the old mods anyway. I don't see many non-EE players trying out my stuff. It really makes me wonder why I should go through all the extra effort ... Link to comment
subtledoctor Posted November 20, 2016 Author Share Posted November 20, 2016 Hrmm. Getting a parse error on this and multiple variations of it: ACTION_IF NOT VARIABLE_IS_SET %EE_LANGUAGE% BEGIN COPY_EXISTING ~leat01.itm~ ~override~ READ_STRREF 0x08 ac_string BUT_ONLY ACTION_FOR_EACH lang IN ~en_US~ ~pl_PL~ ~de_DE~ ~es_ES~ ~fr_FR~ ~cs_CZ~ ~ru_RU~ ~ko_KR~ WITH_TRA ~scales_of_balance/language/%lang%/armor.tra~ BEGIN OUTER_SPRINT ac_lang @10001 END ACTION_IF NOT (~%ac_string%~ STRING_CONTAINS_REGEXP ~%ac_lang%~) BEGIN OUTER_SPRINT yaras_lang %lang% END END ENDEDIT - even when I comment that out, I still get parse errors for this: ACTION_IF VARIABLE_IS_SET %EE_LANGUAGE% BEGIN OUTER_SPRINT ee_lang %EE_LANGUAGE% ACTION_IF FILE_EXISTS ~scales_of_balance/language/%yaras_lang%/armor.tra~ BEGIN OUTER_SPRINT yaras_lang %EE_LANGUAGE% END END ACTION_IF NOT VARIABLE_IS_SET %yaras_lang% BEGIN OUTER_SPRINT yaras_lang ~en_US~ END WITH_TRA EVAL ~scales_of_balance/language/%yaras_lang%/armor.tra~ BEGIN OUTER_SPRINT catch_ac @10001 OUTER_SPRINT dragon_tra @10011 OUTER_SPRINT elven_tra @10012 END Link to comment
agb1 Posted November 20, 2016 Share Posted November 20, 2016 BEGIN at the end of ACTION_FOR_EACH? Link to comment
subtledoctor Posted November 20, 2016 Author Share Posted November 20, 2016 Okay good eyes. But, even with that fixed I still get a parse error at the line beginning "WITH_TRA." And if I comment out that whole first block, I get a parse error at the WITH_TRA line in the second block. A reasonable conclusion might be that I am using WITH_TRA incorrectly... But as usual, I cannot tell from the Weidu readme what I'm doing wrong or how it is supposed to be phrased. WITH_TRA traName list BEGIN TP2 Action list END Isn't that what i did?? Link to comment
agb1 Posted November 20, 2016 Share Posted November 20, 2016 Get rid of the EVAL after WITH_TRA. Link to comment
subtledoctor Posted November 20, 2016 Author Share Posted November 20, 2016 No difference. Link to comment
agb1 Posted November 20, 2016 Share Posted November 20, 2016 Are you using WeiDU v240? Link to comment
argent77 Posted November 20, 2016 Share Posted November 20, 2016 For the SPRINT commands you have to enclose the string variables in quote characters. Without it WeiDU assumes that '%' itself is the quote character and simply stores the string "EE_LANGUAGE" into the variables ee_lang and yaras_lang. ACTION_IF VARIABLE_IS_SET %EE_LANGUAGE% BEGIN OUTER_SPRINT ee_lang ~%EE_LANGUAGE%~ ACTION_IF FILE_EXISTS ~scales_of_balance/language/%yaras_lang%/armor.tra~ BEGIN OUTER_SPRINT yaras_lang ~%EE_LANGUAGE%~ END END ACTION_IF NOT VARIABLE_IS_SET %yaras_lang% BEGIN OUTER_SPRINT yaras_lang ~en_US~ END WITH_TRA EVAL ~scales_of_balance/language/%yaras_lang%/armor.tra~ BEGIN OUTER_SPRINT catch_ac @10001 OUTER_SPRINT dragon_tra @10011 OUTER_SPRINT elven_tra @10012 END Link to comment
agb1 Posted November 20, 2016 Share Posted November 20, 2016 Also note you used yaras_lang for the first FILE_EXISTS - probably meant to use ee_lang. Link to comment
subtledoctor Posted November 20, 2016 Author Share Posted November 20, 2016 No joy. I keep trying different stuff, fixing all of that, but this still gives me a parse error at the WITH_TRA line: ACTION_IF NOT VARIABLE_IS_SET %EE_LANGUAGE% BEGIN COPY_EXISTING ~leat01.itm~ ~override~ READ_STRREF 0x08 ac_string BUT_ONLY ACTION_FOR_EACH lang IN ~en_US~ ~pl_PL~ ~de_DE~ ~es_ES~ ~fr_FR~ ~cs_CZ~ ~ru_RU~ ~ko_KR~ BEGIN WITH_TRA lang_tra ~scales_of_balance/language/%lang%/armor.tra~ BEGIN OUTER_SPRINT ac_lang @10001 END ACTION_IF NOT (~%ac_string%~ STRING_CONTAINS_REGEXP ~%ac_lang%~) BEGIN OUTER_SPRINT yaras_lang ~%lang%~ END END END Link to comment
argent77 Posted November 20, 2016 Share Posted November 20, 2016 "lang_tra" doesn't look like it should belong to the WITH_TRA statement. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.