Updating the translation file

Started by Baguettator, Fri 22/10/2021 12:14:22

Previous topic - Next topic

Baguettator

Hi !

So I come back about problems with the translation file.

My game has been translated in english, but as it  has evolved a lot, I need to update the translation. Many new texts, and many of old texts have been changed (sometimes only 1 letter, but, it changed).

When I update the transcription file in the editor, if a text is different than before, it adds a new line at the end of the transcription file, and the old line is kept.

Because so many lines changed, and it would be too long to tweak it manually, I tried to create a little program with AGS to "update" the transcription file, so that it doesn't stock anymore old texts that re not used anymore.

To do that, I copy the texts of the old transcription file, paste them in a new txt file called "original".

Then I create a new transcription file, copy all the lines (so there are all the texts really used in the game actualized) and paste them in a new txt file called "nouveau".

Then I create a new txt file called "frais" where I write all the lines really used in the game (so those which are in both "nouveau" and "original", with their translation if it has been done in the past).

These txt files are placed in the savegame directory, so the program can access to them easily.

This allow me to have a fresh transcription file, with all the translation of the texts that didn't change from the earlier version, and the new texts that need now a translation. Instead of having a transcription file of thousands of lines, because texts not used are still there since several past versions...

The problem is that I'm french, and it seems to really work nice (the program, I mean), but the functions WriteRawLine support very badly the letters like À É é â etc... Also, the txt file "frais" is written by the program (made with AGS), and is saved as ANSI. It should be UTF-8  I think, because "nouveau" and "original" are both in UTF-8 (and "frais" was also in "UTF-8 before the program writes in it).

Also, it seems that there is a limit, if the text is too long, the WriteRawLine is stopped. The text is cut at the middle (somewhere I presume).

I don't know how to do with that ? It will make me gain a lot of time to get it working.

Here I compiled my program with the 3 txt files needed ("frais" is blank, the others have the needed texts).

https://drive.google.com/file/d/1WfQJnNt_yCGsRK73CyUedJWCkwxPrMbG/view?usp=sharing

Hope someone could help me !

Baguettator

EDIT : oh ok, I managed to correct the code so it's near to perfection :)

The problem is : the function ReadRawLineBack seems to limit the reading to 199 characters.

So some long texts of the translation are cut. And strange things happen then in my file.

Why is there a limit of 199 ? Is it possible to do it another way ?

Crimson Wizard

200 actually, but last is for the null-terminator (i think). 200 was the hardlimit of the old-style "string" type in the ancient versions of AGS, which worked as a fixed-size buffer of chars, and ReadRawLineBack retained that limitation internally.

What you may do is to read in a loop and append to final string until the string is less than 199 chars:
Code: ags

String fullstring = "";
do {
    String s = file.ReadRawStringBack();
    fullstring = fullstring.Append(s);
} while (s.Length == 199);


BTW, 3.6.0 will support UTF-8 translations (you may check the 3.6.0 alpha forum thread in the releases subforum).

Baguettator

Worked perfectly ! Many thanks Crimson !

By interest : what's this function "do" ? How it works and for which use ?

Crimson Wizard

Quote from: Baguettator on Fri 22/10/2021 21:52:33
By interest : what's this function "do" ? How it works and for which use ?

"do" is a loop operator, there are three of them: "do ... while", "while ..." and "for".
Some articles from the manual:
Loops (bit outdated and only has "while" example): https://adventuregamestudio.github.io/ags-manual/ScriptingTutorialPart2.html#loops
Keywords (explains all three): https://adventuregamestudio.github.io/ags-manual/ScriptKeywords.html#while


Baguettator

Oh nice, interesting ! Thanks !

Would it be possible to remove the limit for the functions like ReadRawLine ? Also for the length of the lines in the editor ? That's why it's an obligation to use string.Append to stock long texts into a string.

Crimson Wizard

#6
Quote from: Baguettator on Sat 23/10/2021 11:41:34
Would it be possible to remove the limit for the functions like ReadRawLine ? Also for the length of the lines in the editor ? That's why it's an obligation to use string.Append to stock long texts into a string.

Yes I think this may be done.
I've already removed the script line limit, it's going to be added to 3.6.0.

Although, proper fix would also be to allow to wrap strings in script, as many programming languages allow to do. But idk if it's easy to make with the current script compiler becuase it is a complicated program, and also written in a "dirty" code.

Note that you also may use String.Format to combine strings, this might be slightly more convenient to write:
Code: ags

String s = String.Format("%s%s%s",
      "first part",
      "second part",
      "third part");

SMF spam blocked by CleanTalk