Author Topic: Question to LAM bgee_language  (Read 13263 times)

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Question to LAM bgee_language
« on: November 14, 2013, 01:59:48 PM »
As far as I see, you defined a WeiDU Macro called bgee_language that takes the tra-files out of tra\bgee\%LANGUAGE% instead of tra\%LANGUAGE% ?

Will this also work in combination with USING, e.g.


  ACTION_IF GAME_IS ~tob bg2ee~ THEN BEGIN
    COMPILE ~C#Ajantis_SvA\Dialogues\ToB_only.d~
USING ~C#Ajantis_SvA\Tra\%s\C#AjanJ_pr.tra~
  END

Will the correct tra files be used in this case, as well? Is there a description to this macro somewhere? I didn't find any by using a search engine.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #1 on: November 14, 2013, 04:51:45 PM »
It's actually not a WeiDU macro. It's part of RR. It's defined in "rr/lib/lib.tpa":
Code: [Select]
DEFINE_ACTION_MACRO bgee_language BEGIN
  ACTION_IF GAME_IS ~bgee bg2ee~ BEGIN
    LOAD_TRA ~rr/tra/bgee/english/game.tra~
    LOAD_TRA ~rr/tra/bgee/%LANGUAGE%/game.tra~
  END
END

It will unfortunately do nothing for instances of USING, AUTO_TRA and other instances of LOAD_TRA. It just affects "setup.tra" (the tra files you declare as part of the LANGUAGE statement).

There's a not completely terrible solution for USING and LOAD_TRA. You declare a %tra_path% variable in your ALWAYS block and change your USINGs and LOAD_TRAs into using the %tra_path% variable instead of hardcoding the path.
Code: [Select]
ALWAYS
  ACTION_IF GAME_IS ~bgee bg2ee~ BEGIN
    OUTER_SPRINT tra_path ~mymod/tra/bgee~
  END ELSE BEGIN
    OUTER_SPRINT tra_path ~mymod/tra~
  END
END

// elsewhere

COMPILE ~mymod/foo.d~ USING ~%tra_path%/%LANGUAGE%/foo.tra~
LOAD_TRA ~%tra_path%/%LANGUAGE%/bar.tra~
The saving grace here is that %tra_path% is not something you will have to undo if and when a proper solution materialises.

I'm afraid there's no good solution for AUTO_TRA (at least, not that I can think of), since AUTO_TRA declares the path unconditionally, before you get the chance to define anything yourself.

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #2 on: November 15, 2013, 10:31:52 AM »
Thank you! Macros scare me so much I didn't even start to look in the libraries. Thank you for the suggested code, too.

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #3 on: November 15, 2013, 11:01:12 AM »
No good solution for AUTO_TRA:

Do I see it right that my possibilities are either:

1. put all tra lines in the setup.tra (There are 53 tra files, the thought alone scares me to death.) and use the bgee_language macro

2. use your suggested code above and either specify every single tra file by USING or load the tra file before compiling the .d by LOAD_TRA,  (There are 53 tra files in my mod and the thought alone...)

Is there any possibility to automate the USING / LOAD_TRA command using something like "SPRINT dfile_name ~%SOURCE_RES%~" or something like that..?

Does anyone have a better idea for this?


Offline DavidW

  • Planewalker
  • *****
  • Posts: 286
Re: Question to LAM bgee_language
« Reply #4 on: November 15, 2013, 01:43:37 PM »
I have a better idea (that falls short of being optimal): treat (e.g.) "German (for original game)" and "German (for Enhanced Edition)" as different languages.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #5 on: November 15, 2013, 01:57:02 PM »
While mucking around with Edwin Romance's tra files (w/ AUTO_TRA), I wrote some functions that automate the AUTO_TRA -> USING conversion, with a fairly minimal amount of extra typing. Soon as I have tested them I'll post them and see if they're to anyone's taste.
Well, that didn't work. Compiling D files one by one (like you have to do with USING) runs afoul of all the D/DLG interdependencies.
« Last Edit: November 15, 2013, 02:28:42 PM by Wisp »

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #6 on: November 15, 2013, 02:13:20 PM »
I love you both. :)

Very eager to hear more about your functions, Wisp, but DavidW: your idea is also truly genius. (Now I only need a mass converting tool I actually get to run.)

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: Question to LAM bgee_language
« Reply #7 on: November 16, 2013, 03:07:38 PM »
Still struggling with this -

http://forum.baldursgate.com/discussion/12677/localisation-of-mods-for-bgee#latest

Declaring and then loading using LOAD_TRA does not seem to do the job.

DavidW's idea works, I assume becasue something hinkey is going on within LANGUAGE.

So,
on BGII:EE and WeiDU v235,
Code: [Select]
ALWAYS
ACTION_IF GAME_IS ~bg2ee~ BEGIN
OUTER_SPRINT tra_version ~c-aranw_cp1252~
END ELSE BEGIN
OUTER_SPRINT tra_version ~c-aranw_utf8nb~
END
END

LANGUAGE ~English_BG2EE~ ~English~ ~aranw\tra\english\c-aranw_utf8nb.tra~
LANGUAGE ~English_BG2~ ~English~ ~aranw\tra\english\c-aranw_cp1252.tra~
results in a working .tp2

but using LOAD_TRA and USING ~aranw/tra/%LANGUAGE%/%tra_version%.tra~ in multiple configurations does not seem to work .

Specifically, with

Code: [Select]
ALWAYS
ACTION_IF GAME_IS ~bg2ee~ BEGIN
OUTER_SPRINT tra_version ~c-aranw_cp1252~
END ELSE BEGIN
OUTER_SPRINT tra_version ~c-aranw_utf8nb~
END
        LOAD_TRA  ~aranw\tra\english\%tra_version%.tra~
END

 LANGUAGE ~English~ ~English~ ~aranw\tra\english\%tra_version%.tra~


results in the following:

Code: [Select]
WeiDU v 23500 Log

 C:\Program Files (x86)\BeamDog\Games\00546\setup-aranw.exe
[./chitin.key] loaded, 843510 bytes
[./chitin.key] 185 BIFFs, 59857 resources
[.\weidu.conf] loaded, 17 bytes
[lang\en_us/dialog.tlk] loaded, 13189457 bytes
[lang\en_us/dialog.tlk] 114144 string entries
Using Language [English]
[English] has 1 top-level TRA files

Using lang\en_us/dialog.tlk

Would you like to display the readme? [Y]es [N]o
ERROR: No translation provided for @1
Continuing despite error.

Install Component [UNDEFINED STRING:   @1]?
[I]nstall, or [N]ot Install or [Q]uit? ERROR: No translation provided for @157
Continuing despite error.
ERROR: No translation provided for @160
Continuing despite error.
ERROR: No translation provided for @161
Continuing despite error.
ERROR: No translation provided for @162
Continuing despite error.
ERROR: No translation provided for @164
Continuing despite error.
ERROR: No translation provided for @167
Continuing despite error.
ERROR: No translation provided for @168
Continuing despite error.
ERROR: No translation provided for @169
Continuing despite error.
ERROR: No translation provided for @170
Continuing despite error.
ERROR: No translation provided for @171
Continuing despite error.
Saving This Log:

WeiDU Timings
load TLK                         0.000
parsing .log files               0.000
unmarshal KEY                    0.016
loading files                    0.016
Parsing TP2 files                0.016
stuff not covered elsewhere      0.031
unmarshal TLK                    0.078
TOTAL                            0.156

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #8 on: November 16, 2013, 03:18:22 PM »
Still struggling with this
LANGUAGE is evaluated before ALWAYS, so you can't put variables in there like that. If you are not using AUTO_TRA, I would suggest you use something similar to bgee_language (invoked in your ALWAYS block; overrides the relevant tra files loaded by LANGUAGE) and %tra_path% (set in your ALWAYS block; used to softcode your tra files in USING and LOAD_TRA).
I've been meaning to write a summary of ways of dealing with the charset issue, but I've been super busy and haven't yet had time.

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: Question to LAM bgee_language
« Reply #9 on: November 16, 2013, 03:50:01 PM »
So in order to do this correctly,

1. Declare LANGUAGE with a "hardcoded" default (so the .tp2 can fall back on it)
2. Override the default language in the ALWAYS block.

Code: [Select]
ALWAYS
ACTION_IF GAME_IS ~bg2ee~ BEGIN
OUTER_SPRINT tra_version ~c-aranw_utf8nb~
    LOAD_TRA ~aranw\tra\english\c-aranw_utf8nb.tra~
    LOAD_TRA ~aranw\tra\%LANGUAGE%\c-aranw_utf8nb.tra~
END ELSE BEGIN
OUTER_SPRINT tra_version ~c-aranw_cp1252~
    LOAD_TRA ~aranw\tra\english\c-aranw_cp1252.tra~
    LOAD_TRA ~aranw\tra\%LANGUAGE%\c-aranw_cp1252.tra~
END
END

LANGUAGE ~English~ ~English~ ~aranw\tra\english\c-aranw_cp1252.tra~


Edit: Tested - works. It loads the tra twice, which is fine by me. Checking the dialog.tlk shows that the lines are appended just fine.
« Last Edit: November 16, 2013, 03:59:42 PM by cmorgan »

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #10 on: November 17, 2013, 02:52:31 AM »
Do I see it right that the setup.tra (where the mod title is taken from) has to be in the path specified by LANGUAGE?

Or, that ALWAYS is processed after the BEGIN of the mod?

I tried copying the correct tras into the LANGUAGE folder before the install, having empty language folders at the beginning and "bgii" and "utf8" language subfolders. I tried using the ALWAYS block for copying the tras into the folders specified by the LANGUAGE path, but it gave me an "unspecified string" instead of the mod name.

I tried specifying the setup.tra in the ALWAYS block but this didn't work, either (the mod name string is unknown):

Code: [Select]
ALWAYS
ACTION_IF GAME_IS ~bgee bg2ee~ BEGIN

LOAD_TRA ~C#Ajantis_SvA\Tra\utf8\english\Setup-C#Ajantis_SvA.tra~
LOAD_TRA ~C#Ajantis_SvA\Tra\utf8\%LANGUAGE%\Setup-C#Ajantis_SvA.tra~

COPY ~C#Ajantis_SvA\Tra\utf8\%LANGUAGE%~ ~C#Ajantis_SvA\Tra\%LANGUAGE%~

END ELSE BEGIN

LOAD_TRA ~C#Ajantis_SvA\Tra\bgii\english\Setup-C#Ajantis_SvA.tra~
LOAD_TRA ~C#Ajantis_SvA\Tra\bgii\%LANGUAGE%\Setup-C#Ajantis_SvA.tra~

END
END

I like the idea of copying the correct tras into the LANGUAGE folder, as it saves me a lot of hassle. How would I do that so the installer knows the mod's name?
Sorry for all my questions, I am still trying to understand all this.

EDIT: The reason why I want to have both folders is the re-installability. If I have the windows-1252 encoded files in the LANGUAGE folder and the the UTF-8 ones get copied there upon install, I fear the windows-1252 files are lost after uninstallation of the mod?
This could be solved via to-and fro-copying upon install and uninstall, but I fear I don't really know what I am doing.

EDIT2: Or maybe my copy command doesn't work. I used
Code: [Select]
ALWAYS
ACTION_IF GAME_IS ~bgee bg2ee~ BEGIN
COPY ~C#Ajantis_SvA\Tra\utf8\%LANGUAGE%~ ~C#Ajantis_SvA\Tra\%LANGUAGE%~
END ELSE BEGIN
COPY ~C#Ajantis_SvA\Tra\bgii\%LANGUAGE%~ ~C#Ajantis_SvA\Tra\%LANGUAGE%~
END
END

but it doesn't copy any files into the %LANGUAGE% folder.
« Last Edit: November 17, 2013, 03:06:28 AM by jastey »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #11 on: November 17, 2013, 06:19:12 AM »
Hey, neat idea! Yeah, copying works, and as far as workarounds go, it's pretty unintrusive.

Using Edwin Romance as an example:
Code: [Select]
AUTO_TRA ~edwin/tra/%s~ // Your normal AUTO_TRA declaration (not that we have a choice)

ALWAYS
  ACTION_IF GAME_IS ~bg2ee~ BEGIN
    OUTER_SPRINT tra_path ~%MOD_FOLDER%/tra/bgee~
  END ELSE BEGIN
    OUTER_SPRINT tra_path ~%MOD_FOLDER%/tra~
  END

  /*
   * Loads UTF8-encoded tra files to replace those loaded by LANGUAGE
   */
  DEFINE_ACTION_MACRO bgee_language BEGIN
    ACTION_IF GAME_IS ~bgee bg2ee~ BEGIN
      LOAD_TRA ~%MOD_FOLDER%/tra/bgee/english/game.tra~
      LOAD_TRA ~%MOD_FOLDER%/tra/bgee/%LANGUAGE%/game.tra~
    END
  END

  /*
   * Copies UTF8-encoded tra files over the normal ones, for use with AUTO_TRA
   */
  DEFINE_ACTION_FUNCTION autotra_workaround BEGIN
    COPY ~%MOD_FOLDER%/tra/bgee/%LANGUAGE%~  ~%MOD_FOLDER%/tra/%LANGUAGE%~
  END

  LAM bgee_language
  LAF autotra_workaround END
END

/*
 * In LANGUAGE, tra files have been split into different files depending on what they are used for
 * Strings that are displayed in the game need to follow the game's encoding
 * Strings that are displayed during the installation (component names, etc.) need to follow the OS's encoding
 * Additionally, since different OSs use different encodings, there is need for one file per OS
 * Accordingly:
 * game.tra: encoded in whatever charset is used by the target game, UTF8 and "normal" copies are needed
 * setup-win32.tra: encoded in whatever local charset is used by Windows for the relevant language
 * setup-osx.tra: encoded in UTF8
 * setup-unix.tra: encoded in UTF8
 * This is obviously as optional as you want to make it, and multiple setup-*.tra files can be safely omitted
 * for languages or translations that don't need special encodings (typically English, for example)
 */
LANGUAGE ~American English~
         ~english~
         ~edwin/tra/english/game.tra~ // Holds text displayed in the game
         ~edwin/tra/english/setup.tra~ // Holds text displayed during the installation

LANGUAGE ~Francaise~
         ~french~
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/french/game.tra~
         ~edwin/tra/french/setup-%WEIDU_OS%.tra~

LANGUAGE ~Espanol~
         ~spanish~
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/spanish/game.tra~
         ~edwin/tra/spanish/setup-%WEIDU_OS%.tra~

LANGUAGE ~Russian~
         ~russian~
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/russian/game.tra~
         ~edwin/tra/russian/setup-%WEIDU_OS%.tra~

LANGUAGE ~Deutsch~
         ~german~
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/german/game.tra~
         ~edwin/tra/german/setup-%WEIDU_OS%.tra~

LANGUAGE Polish
         polish
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/polish/game.tra~
         ~edwin/tra/polish/setup-%WEIDU_OS%.tra~

LANGUAGE ~Simplified Chinese~
         schinese
         ~edwin/tra/english/game.tra~
         ~edwin/tra/english/setup.tra~
         ~edwin/tra/schinese/game.tra~
         ~edwin/tra/schinese/setup-%WEIDU_OS%.tra~

// further down

//Dialogues (compiled with AUTO_TRA)
COMPILE
~edwin/dlg/eredwinp.d~
~edwin/dlg/eredwinj.d~
~edwin/dlg/ervicon.d~
~edwin/dlg/ermazzy.d~
~edwin/dlg/eranomen.d~
~edwin/dlg/erelvira.d~
~edwin/dlg/erlovetalk2.d~
~edwin/dlg/erterl02.d~
~edwin/dlg/eredwina2.d~
~edwin/dlg/eredwina.d~
~edwin/dlg/erlovetalk.d~
~edwin/dlg/erimoen.d~

// yet further down

// Compiled with USING; %tra_path% is redundant in this case, but I'm including it as a demonstration
COMPILE ~edwin/dlg/erlovetalk25.d~ USING
          ~%tra_path%/english/erlovetalk25.tra~
          ~%tra_path%/%LANGUAGE%/erlovetalk25.tra~
« Last Edit: November 17, 2013, 06:27:17 AM by Wisp »

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #12 on: November 17, 2013, 06:33:30 AM »
Thank you very much for this.

I have more questions.  :-[

In your example, what happens upon uninstall from a BGII:EE game? Will the former encoded tra files be in the LANGUAGE folder again?

Question to game.tra: Is this a standard like setup.tra? Because in my case, setup.tra also contains text that will show in the game (item descriptions, etc.). Is this externalized in game.tra for the current WeiDU? I totally missed this.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #13 on: November 17, 2013, 06:53:30 AM »
In your example, what happens upon uninstall from a BGII:EE game? Will the former encoded tra files be in the LANGUAGE folder again?
Yes, the "normal" TRA files will be restored upon uninstallation.

Question to game.tra: Is this a standard like setup.tra? Because in my case, setup.tra also contains text that will show in the game (item descriptions, etc.). Is this externalized in game.tra for the current WeiDU? I totally missed this.
"setup.tra" is just a convention. You can use LANGUAGE to load whatever TRA files you wish, they just can't overlap, or they'll shadow one another. In this case, you split your TRA file into two parts, encode them separately and load them at the same time (in LANGUAGE). The end result is identical to if you had had a single TRA file, except that you can use different encodings. Your new "game.tra" contains the text for creature names, item descriptions etc., and "setup.tra" is left with component names and such.

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #14 on: November 17, 2013, 11:04:27 AM »
Thank you! Heaven! Peace! It is working!  8)

Offline Isaya

  • Planewalker
  • *****
  • Posts: 47
Re: Question to LAM bgee_language
« Reply #15 on: November 17, 2013, 12:51:30 PM »
The BG1 NPC beta version, which uses on the fly conversion of the tra files, uses a similar method in order to keep the files in the directory specified through LANGUAGE and maintain compatibility with AUTO_TRA. Although, instead of COPY, it uses MOVE, which is also reversed at uninstall. Another difference is that I used MOVE on a file by file basis.

The example of BG1 NPC also taught me another lesson: if your mod has several components, beware of ALWAYS, as it is run with every component. So you're going to copy the tra files over and over and your backup directory will grow unexpectedely.

In BG1 NPC, due to the fact that the first component, required, evaluates tra files using the suffix _tmp and generates tra files without the _tmp part, I used an ACTION_IF to check for the existence of the resulting file to determine whether the operation had already been done and avoid repeating it. In case of on the fly conversion, this is very important since the file in the directory could already be converted and iconv doesn't behave well when you tell it to convert from CP1252 while it's actually already UTF-8, as the secondary byte in UTF8 for a special character can be seen as a special character as well in CP1252, so it converts it and the result is garbage and probably invalid UTF-8 code.

When using premade separate sets for CP1252 and UTF-8 in a multi-component mod, I would still advise some protection be used in ALWAYS. I'm not sure it's possible to use a variable. I have the feeling they are reset when we move to another component. I believe creating an fake file after copying the tra files and checking for its presence to avoid copying again would work.

Here is an example of how it's done in BG1 NPC (this code is slightly different from the GitHub code as I added Linux and Mac handling, and I didn't submit it to cmorgan yet)
Code: [Select]
ACTION_IF FILE_EXISTS_IN_GAME ~neera.dlg~ THEN BEGIN
  /*Tell the player it is using BG:EE stuff */
  PRINT @5000
  INCLUDE ~bg1npc\lib\liam_bgee_vars.tpa~
  OUTER_SPRINT ~bgee~ ~bgee/~

  // BG:EE tra conversion
  // Character encoding for BG II for various languages: ensure the name matches the menu choices
  ACTION_DEFINE_ASSOCIATIVE_ARRAY languageencoding BEGIN
"french" => "CP1252"
"spanish" => "CP1252"
  END
  OUTER_SPRINT initialencoding ~~
  ACTION_PHP_EACH languageencoding AS lang => encoding BEGIN
    ACTION_IF ("%LANGUAGE%" STRING_EQUAL_CASE ~%lang%~ = 0) THEN BEGIN
      OUTER_SPRINT initialencoding ~%encoding%~
    END
  END
  // Isaya: check for existence of BG1NPC/TRA/%LANGUAGE%/BG1NPC.tra as a marker that the mod
  // has already installed at least one component, so conversion is already done, in order
  // to avoid repeating for each component (as a backup of all tra files is then done in each
  // subdirectory of backup)
  // This is a handy trick with BG1 NPC, since BG1NPC.tra is created when the mod is installed
  // and removed with the mod. But it cannot be used as a generic trick for other mods.
  ACTION_IF NOT (FILE_EXISTS_IN_GAME ~bg1npc/tra/%LANGUAGE%/BG1NPC.tra~) AND
            (STRING_LENGTH ~%initialencoding%~ != 0) THEN BEGIN
    ACTION_IF ("%WEIDU_OS%" STRING_EQUAL_CASE ~WIN32~ = 0) THEN BEGIN
      // Only convert for the language selected by passing the directory as parameter
      AT_NOW ~bg1npc/conv_tra.bat %LANGUAGE% %initialencoding%~
    END
    ACTION_IF ("%WEIDU_OS%" STRING_EQUAL_CASE ~OSX~ = 0) OR ("%WEIDU_OS%" STRING_EQUAL_CASE ~UNIX~ = 0) THEN BEGIN
      // Only convert for the language selected by passing the directory as parameter
      AT_NOW ~bg1npc/conv_tra.sh %LANGUAGE% %initialencoding%~
    END
    // Isaya: all tra files have to be renamed from .tra_utf8 to .tra!
    // Otherwise the tra files for dialogs are still with the Windows 1252 encoding
    MOVE ~bg1npc/tra/%LANGUAGE%/bg1npc_tmp.tra_utf8~ ~bg1npc/tra/%LANGUAGE%/bg1npc_tmp.tra~
    ... MOVE all tra files

    LOAD_TRA ~bg1npc/tra/%LANGUAGE%/setup.tra~
    PRINT ~re-loaded %LANGUAGE% TRA files~
  END

END ELSE BEGIN
  ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
    /* Tell the player it is using Tutu stuff */
    PRINT @1000
    INCLUDE ~bg1npc\lib\g3_tutu_cpmvars.tpa~
    OUTER_SPRINT ~bgee~ ~~
  END ELSE BEGIN
    ACTION_IF FILE_EXISTS_IN_GAME ~AR7200.are~ THEN BEGIN
        /* Tell the player it is using BGT stuff */
        PRINT @1001
        INCLUDE ~bg1npc\lib\g3_bgt_cpmvars.tpa~
        OUTER_SPRINT ~bgee~ ~~
        /* Tell the player it is not Tutu or BGT */
    END ELSE BEGIN FAIL ~Please install on BG:EE, Tutu or BGT.~
    END
  END
END
with conv_tra.bat
Code: [Select]
:: Use a parameter to the script (%1) to specify the directory that must be converted
:: Use a parameter to the script (%2) to specify the encoding of the files to convert

:: Prevent display of DOS command lines
@echo off

:: Since the pattern matching in Windows considers that "fu.tra_utf8" also matches "*.tra", we have to
:: handle the file extension by ourselfves in order to avoid all those tra_utf8_utf8 etc files
:: Use %%~ni instead of %%~nxi (x is for extension) and specify the tra extension
for %%i in (bg1npc\tra\%1\*.tra) do bg1npc\iconv -f %2 -t UTF-8 "bg1npc\tra\%1\%%~ni.tra" > "bg1npc\tra\%1\%%~ni.tra_utf8"
and conv_tra.sh
Code: [Select]
# Use a parameter to the script ($1) to specify the directory that must be converted
# Use a parameter to the script ($2) to specify the encoding of the files to convert
for file in $(ls bg1npc/tra/$1/*.tra)
do
  iconv -f "$2" -t UTF-8  "$file" > "$file"_utf8
done
I couldn't test conv_tra.sh in a real installation as I don't have the game under my Linux virtual machine but I checked it the script standalone nonetheless.


Wisp, ever since I wrote the code to use MOVE in V231 and now in V235, I'm finding that the foo.tra_utf8 file I ask to move are actually copied under the new name but foo.tra_utf8 is not removed. Do you know if it's this a bug or if there's a reason for that?
« Last Edit: November 17, 2013, 01:10:54 PM by Isaya »

Offline jastey

  • Planewalker
  • *****
  • Posts: 1422
  • Gender: Female
Re: Question to LAM bgee_language
« Reply #16 on: November 17, 2013, 01:34:17 PM »
Thank you for the heads up in regard to a mod with several components, and for sharing the code.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #17 on: November 17, 2013, 01:59:37 PM »
Yeah, the copying should best be done only once. Variables are not unset between components, but you can install one component, quit and install another, so using a marker file is better.

Wisp, ever since I wrote the code to use MOVE in V231 and now in V235, I'm finding that the foo.tra_utf8 file I ask to move are actually copied under the new name but foo.tra_utf8 is not removed. Do you know if it's this a bug or if there's a reason for that?
MOVE only moves if the destination file does not exist. Otherwise it copies.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #18 on: November 17, 2013, 04:44:46 PM »
I'm not entirely sure it is post-worthy, but here is an Edwin-Romance-styled autotra_workaround with a marker file:
Code: [Select]
  DEFINE_ACTION_FUNCTION autotra_workaround BEGIN
    ACTION_IF !FILE_EXISTS ~%MOD_FOLDER%/tra/%LANGUAGE%/utf8.mrk~ BEGIN
      COPY ~%MOD_FOLDER%/tra/bgee/%LANGUAGE%~  ~%MOD_FOLDER%/tra/%LANGUAGE%~
      COPY_EXISTING sw1h01.itm ~%MOD_FOLDER%/tra/%LANGUAGE%/utf8.mrk~
    END
  END

If it's desirable I'll try to find the time to summarise the current state of the art in dealing with the UTF8 situation (essentially, summarising and highlighting parts of this thread). This is likely as good as it is going to get until such time, if ever, that WeiDU is able to do charset conversions.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6252
  • Gender: Female
  • The perfect moment is now.
Re: Question to LAM bgee_language
« Reply #19 on: November 17, 2013, 11:49:22 PM »
Thank you very much for researching the problem, everyone! A tutorial will be very welcome. :)

('If ever' part is a little sad. :( I have no idea how to convert Polish/French/Italian files, since I can't check the result, not knowing the language. I can convert Russian files, sure).


Offline Cahir

  • Planewalker
  • *****
  • Posts: 101
  • Gender: Male
Re: Question to LAM bgee_language
« Reply #20 on: November 18, 2013, 12:40:47 AM »
Kulyok I can check Polish part for you just tell me exactly what to do:)

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6252
  • Gender: Female
  • The perfect moment is now.
Re: Question to LAM bgee_language
« Reply #21 on: November 18, 2013, 01:07:09 AM »
Thank you, I'll be happy to ask for your help(once I know more about what's going on, how to do stuff and when we should expect multilanguage BG2EE releases - since I don't know about them much)!


Offline Cahir

  • Planewalker
  • *****
  • Posts: 101
  • Gender: Male
Re: Question to LAM bgee_language
« Reply #22 on: November 18, 2013, 01:36:32 AM »
Ok just shoot me PM when You figure everything out ;)

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1088
Re: Question to LAM bgee_language
« Reply #23 on: November 18, 2013, 01:43:23 AM »
('If ever' part is a little sad. :( I have no idea how to convert Polish/French/Italian files, since I can't check the result, not knowing the language. I can convert Russian files, sure).
Well, I don't want to get anyone's hopes up prematurely. And even if WeiDU will be able to offer something substantial to help with this, it won't be magic. At a minimum, WeiDU would have to know the charset used for the input text (and it would have to be a single charset). So it would operate under pretty much the same constraints you're under when you use iconv today.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6252
  • Gender: Female
  • The perfect moment is now.
Re: Question to LAM bgee_language
« Reply #24 on: November 18, 2013, 07:16:45 AM »
I'm looking at Edwin Romance's files right now, and it looks elegant and simple. I hope can replicate that(I don't have /tra folder, so I'll just create /BG2EE/German and such).

But what exactly should I do with the .tra files I have, how do I get BG2EE files out of them? I obviously can't read anything, but I see the visual difference between the files, so maybe I can do this. Btw, is there a way to convert all the files at once, not one-by-one?

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: