Author Topic: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA  (Read 1299 times)

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« on: January 28, 2021, 05:50:54 AM »
Hi,

At the time when I was so happy to have UTF8 solution for HANDLE_CHARSETS and removing all of its quirks by using out_path parameter with a different path, it turns out that using out_path is incompatible with AUTO_TRA. If the out_path path is provided, AUTO_TRA path is ~MyMod\tra\%s~ and you are using from_utf8 = 1 then installing the mod on classic games will not load converted files, it will load UTF8-ones that causes malformed characters.

My first thought was: put the same path of out_path for AUTO_TRA and add \%s to it. I can provide a full code example if it's needed.
Code: [Select]
LAF HANDLE_CHARSETS
        INT_VAR
            from_utf8 = 1
            infer_charset = 1
            verbose = 1
        STR_VAR
            tra_path = "MyMod\lang"
            out_path = "weidu_external\lang\%MOD_FOLDER%"
    END
Quote
//AUTO_TRA ~MyMod\lang\%s~ // not this
AUTO_TRA ~weidu_external\lang\MyMod\%s~ //this

1. Does such a workaround is valid?
2. If not, can you please make HANDLE_CHARSETS out_path compatible with AUTO_TRA?
« Last Edit: January 28, 2021, 06:29:10 AM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #1 on: April 18, 2021, 02:34:16 AM »
You can use whatever path you like for AUTO_TRA, provided that's from where you want your TRA files loaded. Just bear in mind out_path is only used if the conversion runs, which it won't unless it thinks it needs to run (because the target game uses a different encoding than the one converted from).

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #2 on: April 18, 2021, 03:05:31 AM »
Very good news! The since translation source files are UTF8, out_path will always be used for classic games, as expected.
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #3 on: June 28, 2021, 06:18:58 PM »
You can use whatever path you like for AUTO_TRA, provided that's from where you want your TRA files loaded. Just bear in mind out_path is only used if the conversion runs, which it won't unless it thinks it needs to run (because the target game uses a different encoding than the one converted from).

I read this again and now I get what you mean. The conversion doesn't happen on EE games when source files already have UTF8 encoding.

That's a problem for AUTO_TRA:

- when I install the example code on classic games, the conversion is run, the AUTO_TRA will load files from ~weidu_external\lang\MyMod\%s~
- when I install the example code on EE games, the conversion won't run, the AUTO_TRA will fail to load files from ~weidu_external\lang\MyMod\%s~

as the consequences, COMPILE EVALUATE_BUFFER "...\xxx.d" won't find proper .tra files. The workaround that I currently use is to add "USING" to COMPILE but that's negating AUTO_TRA usage.

My first idea was to set different path values for AUTO_TRA, using ALWAYS block and set helper variable as "MyMod\lang\%s" for EE and "weidu_external\lang\MyMod\%s" for classic games
Code: [Select]
ALWAYS
    ACTION_IF (GAME_IS ~bgee eet~) THEN BEGIN
        OUTER_SPRINT "AUTOTRA_PATH" "MyMod/lang"
    END


    ACTION_IF !(GAME_IS ~bgee eet~) THEN BEGIN
        OUTER_SPRINT "AUTOTRA_PATH" "weidu_external/lang/MyMod"
    END
END

AUTO_TRA ~%AUTOTRA_PATH%/%s~

but no matter what I try it doesn't work. Can you please take look and if possible, make AUTO_TRA accept variable evaluation?
« Last Edit: June 28, 2021, 06:21:56 PM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #4 on: July 05, 2021, 08:39:20 AM »
Having AUTO_TRA evaluate variables should be straight-forward.

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #5 on: July 05, 2021, 09:13:37 AM »
It doesn't for my use-case. Here is the complete code: https://github.com/ALIENQuake/CoranBGFriend/tree/auto_tra_test

Variables are set in ALWAYS:
   
Code: [Select]
ACTION_IF (GAME_IS "bgee eet") THEN BEGIN
        OUTER_TEXT_SPRINT "CURRENT_TRA_PATH" "%MOD_FOLDER%/lang/"
        OUTER_TEXT_SPRINT "AUTOTRA_PATH" "%MOD_FOLDER%/lang/%LANGUAGE%"
    END

    ACTION_IF !(GAME_IS "bgee eet") THEN BEGIN
        OUTER_TEXT_SPRINT "CURRENT_TRA_PATH" "weidu_external/lang/%MOD_FOLDER%"
        OUTER_TEXT_SPRINT "AUTOTRA_PATH" "weidu_external/lang/%MOD_FOLDER%/%LANGUAGE%"
    END

https://github.com/ALIENQuake/CoranBGFriend/blob/auto_tra_test/coranbgfriend/coranbgfriend.tp2#L106

AUTO_TRA ~coranbgfriend/lang/%s~           -  works but no variables are used.

AUTO_TRA ~%CURRENT_TRA_PATH%/%s~  -  use partial path in a variable + %s, doesn't work, I'm getting an error below
AUTO_TRA ~%AUTOTRA_PATH%~               -  use full path in a variable, doesn't work, I'm getting an error below

Error:
Code: [Select]
ERROR: No translation provided for @6
ERROR: parsing [tb#_compile_eval_buffer/coranbgfriend/dlg/p#coranft.d]: Not_found

Can you please help me?
« Last Edit: July 05, 2021, 11:24:47 AM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #6 on: July 05, 2021, 01:22:44 PM »
I apologise for the misunderstanding: I meant I would most likely be able to implement your request. AUTO_TRA does not currently evaluate variables.

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 391
  • Gender: Male
Re: HANDLE_CHARSETS, from_utf8 = 1, out_path and AUTO_TRA
« Reply #7 on: July 05, 2021, 01:59:59 PM »
No problem. Please do, right now I'm back at the beginning where I can't use AUTRO_TRA + HC + UTF8 + out_path so fulfilling this request will spark joy.
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

 

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)?: