Jump to content

TRA file format


Recommended Posts

Hi, I was writing a small tool/script to work on weidu tra files and expected to be, well, not that hard.

But then after naively pumping out code I noticed I had forgotten things.

This is not enough

```

@<id> = ~text~{~text~}

```

(with {...} meaning optional)

Even when allowing both ~ and " as string delimiter (those are the only two, promise?) and comments.

Because I had TRAs with `[sound]` too!

```

@<id> = ~text~{[sound]} {~text~}  {[sound]}

```

And then I found some TRA files with **negative** indexes 😮

Well, looking at the weidu doc, I couldn't find a description of the format, not in the sens that we have a semi-formal description of the .D format. Well it seems maybe it was an extension of .D files themselves(?)

Or do we have one and I couldn't find it? Do I have everything or am I still missing parts:

- comments with `//

- Do we have `/* */` too? Can we put those between `@123` and `=` or somewhere else in the middle of an entry?

- an id in the form `@<number>` including negative numbers

- strings enclosed in tildas (with no tildas inside) or double quotes (with no double quotes inside)

- one or two string with zero, one or two sound labels

- Uh what characters are accepted in the sound label by the way? Probably not `]` I suspect, but any other restriction?

This was supposed to be a peaceful, relaxing, leisurely activity :D (and then "let's write a LALR grammar"...)

Edited by mickabouille
Link to comment
1 hour ago, mickabouille said:

- strings enclosed in tildas (with no tildas inside) or double quotes (with no double quotes inside)

That's not all. Strings can also be enclosed in percent signs (%) or five consecutive tildes (~~~~~). And string concatenation is most likely also supported (string1 ^ string2).

The translation string syntax is mostly covered in the WeiDU D format description (see the Text and String subsections).

Link to comment

Yes, for mods that use burner1024's converter to PO files — you can use any proper translation tool then, including his instance of (pootle). A good way to benefit from a translation memory.

Link to comment
Posted (edited)
11 hours ago, argent77 said:

That's not all. Strings can also be enclosed in percent signs (%) or five consecutive tildes (~~~~~). And string concatenation is most likely also supported (string1 ^ string2).

The translation string syntax is mostly covered in the WeiDU D format description (see the Text and String subsections).

I was hoping this unnecessary cruft would have been banned from TRA to make it an inert data format :D

Wait does that mean you can do that too?

@2 = @1 ^ @109 ^ #234

@1 = @2 ^ @109

 

EDIT: and, eh... This five tildes things is a pain, talk about grammar conflicts 😒

Edited by mickabouille
Link to comment
Posted (edited)

Well, after testing, I'm somewhat relieved to confirm that you can't do

@10 = ~something~ ^ @11

BUT you can do

@10 = @11

@10 = #1234 //also works

And

 

@10 = @11

@11 = @11

is just a stack overflow 😛

EDIT: mostly in sync

Edited by mickabouille
Link to comment
Posted (edited)

And of course you CAN put multiple entries on the same line (I guess you could put your entire TRA file on a single line).

And you can't do

@12 = ~some text~ @13

which I admit would be confusing semantically.

And, (wooot) this works!

@11  = ~Something~ /* comment */ ~Something else~

(sob 🥲)

Edited by mickabouille
Link to comment
5 hours ago, lynx said:

Yes, for mods that use burner1024's converter to PO files — you can use any proper translation tool then, including his instance of (pootle). A good way to benefit from a translation memory.

I didn't understand any of this.

- Who is burner1024?

- What is PO file? Why would i convert to PO file?

- What is pootle?

- How will I know if a mod uses burner1024's converter to PO files? BG1 NPC Project?

- Any proper translation tool? For example? I only know DeepL.

Edited by medic2000
Link to comment
Posted (edited)

So, I just tested

`@11 = ~~~~~~~~~~~~~~`

(How far am I gone?)

and weidu doesn't want anything to do with it (it should mean `~~~~`)

Even `@11 = ~~~~~~~~~~~` doesn't work (it should mean `~`

On the other hand `@11 = ~~~~~ ~~~~ ~~~~~` works and shows `~~~~`

So now my parser is more correct than weidu... which is a problem because I don't intend to RE the exact behavior.

(Seems I am neither on Earth nor on Faerûn, that's maybe be the Fugue plane?)

Edited by mickabouille
Link to comment
33 minutes ago, mickabouille said:

`@11 = ~~~~~~~~~~~~~~`

and weidu doesn't want anything to do with it (it should mean `~~~~`)

Even `@11 = ~~~~~~~~~~~` doesn't work (it should mean `~`

On the other hand `@11 = ~~~~~ ~~~~ ~~~~~` works and shows `~~~~`

So now my parser is more correct than weidu... which is a problem because I don't intend to RE the exact behavior.

You have an empty string "~~~~~~~~~~" followed by four tildes, not four tildes within two instances of "~~~~~".  A string ends at the first instance of it's delimiter.   "~~~~~~~~~~~~" (12x) will work, because it reads two empty strings: "~~~~~~~~~~" and "~~".  If you want tildes within a string like that, you need to use either " or % as the delimiter, or use a variable.

Link to comment

@1 = ~~~~~~~~~~~~ // (12x)
seems to work because WeiDU interprets it as two consecutive string literals (male and female string) without having any whitespace in between.

It is functionally identical to
@1 = ~~~~~~~~~~""
or
@1 = ""~~~~~~~~~~
or even
@1 = ~~~~~~~~~~[]~~[]  // two strings with empty sound references

Link to comment
Posted (edited)

That's disturbing.

Anyway, this five tildes things has no real use (given we already bear the cost of concatenation support) and it I only (barely) care about it because one of my test case (the tra-ified bg1ee tlk) contains

@30    = ~~~~~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*() -_=+\|]}[{;:'",<.>/?–— ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿœŒ€£~°µ~~~~~

 

So I'll probably disregard the more complex cases.

Edited by mickabouille
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...