Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Laura Hunt on Wed 03/02/2021 15:41:11

Title: Re-importing revised text into AGS after proofreading
Post by: Laura Hunt on Wed 03/02/2021 15:41:11
Let's say somebody wants me to proofread their game, so they create a new Translation (let's call it "RevisedText"), dump all their game text into the RevisedText.trs file, and they send it to me. I review the text, fix any mistakes I find, and send it back.

What would be the best way for them to now update their game text with the file I just sent them?

For the record, I tried a couple of approaches that don't seem to work:

- For starters, the translation file won't compile if there aren't any translated lines, so I need to insert a dummy "translated" line somewhere.

- Using Game.ChangeTranslation("RevisedText"); in game_start does nothing.

- Right-clicking on the RevisedText file in the project tree and choosing "Make default language" doesn't seem to work either.

So is there any actual way to more-or-less automate the whole process and re-import the revised text so that it replaces the original game text?

Thanks as always in advance!

(Note: this assumes for simplicity there is only one language, and that no actual translations are being used.)
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Laura Hunt on Wed 03/02/2021 15:49:31
Me to myself, literally 10 seconds after posting: "well, instead of replacing the erroneous text with your corrections, just enter your fixes BELOW each original line so they get treated as a translation, duh".

This phenomenon has to have a name. I literally always come up with a solution as soon as I've posted here.
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Fri 26/02/2021 20:08:59
Well don't worry Laura_hunt because I have a problem that could be linked in this thread :)

Well, my game is in alpha testing, and I have started to add a translation to get more play-testers.

My default language is french, and the translation is english.

We made a first translation of the whole game (2800 lines, uh !), then compile the trs, everything working fine.

But what happens when I add new lines in the game (in french so), because I am adding new features or new texts or modifying some existing texts for better understanding ? What should I have to do ?

Update the transcription file ? I got weird results with that : the file was 4900 lines (against 2800 before), it was like the game didn't recognize the lines we had translated, and generate almost each line at the end of the file. But the lines we had already translated were still in the file, but not recognized (some texts appear non-translated in game).

Well, so my question is : if I have to modify/add new lines to a translation file because the game is getting enhanced or developed, what should I do ?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Cassiebsg on Fri 26/02/2021 20:29:29
If you for instance have misspelled a word or the sentence ended with a . and you went and change it to a !, but you didn't change that in the translation file, then it's technically a new line. AGS will look for the exact sentence match, and then read the translation line, that should be right under it. And I mean exact match, even an extra "invisible" character like a space, will make the line to not be found!

I'm not sure what best practice is, but I'm pretty sure I've changed the translated file at the same time I corrected the lines in game... So you want to add translations as the latest possible time in development, when you're sure you will not change much of what's done, and then all new lines will just be added to the end of the file and not mess up your translations.
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Tue 02/03/2021 18:59:36
Hi again,

So if understand well : when ags compile the translation file, all the lines are written in the file. But I could change the position of a line with its translation, since they are one under the other, it will work as intended ?

So, if I correct a line in the game editor, find it in the translation file and correct the same way this sentence in the transcription file, it will be OK ?

But if I delete a line in the game, but not in the translation file. The game won't get error because it doesn't find the line that doesn't exist anymore ?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Cassiebsg on Tue 02/03/2021 20:08:43
Yes, but make sure you don't save the translation file with the wrong format, since that won't work.

QuoteBut I could change the position of a line with its translation, since they are one under the other, it will work as intended ?

Wait, what are you saying exactly?

The translated line is ALWAYS right bellow the "original line" (the line in script). If you switch the order, put the original bellow the translation, it will get you very weird errors, as it either fail to find the line or give you the wrong translation from then on... In other words, DO NOT mess with the order of the lines.  :)

Technically, you might get away with moving the original line and it's translation and place them elsewhere in the file. I can't remember if there's any line association added for the translation, but think there's not. I haven't tried doing this, but guess you can make a backup of your file and test to see if that works, though not sure if the extra work would benefit you or anyone else though to be honest.
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Khris on Tue 02/03/2021 21:23:18
Afaik, AGS removes all comment lines, then basically puts the remaining lines into two columms; odd lines in the first column, even lines in the second.

So as long as you make sure that the original line, exactly as it appears in your project / script, is in line 1 or 3 or 17 or 263 it's going to be fine (and due to comments, your editor's line numbers will shift constantly, so it's best not to move things around too much. Or use the SpeechCenter plugin).
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Wed 03/03/2021 09:56:57
Quote from: Cassiebsg on Tue 02/03/2021 20:08:43
Wait, what are you saying exactly?

I was saying that I could move the original line WITH its translation anywhere else in the transcription file :)

So if I understand well, my translation file has been compiled in V1.0, and if I need to update some lines and add new ones for a V1.1, I just need to correct the sentence both in the editor and in the translation file (this way the game will recognize the new corrected line with its corrected translation), and then update the translation file in the editor, that will add the new lines I have added in my game at the end of the translation file, finally I translate them in the translation file and everything will be ok ?

Sorry for my english, I hope it is understandable...
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Monsieur OUXX on Wed 03/03/2021 10:23:11
(For advanced users only) On the topic of iterative translations and how to revise them, here is what we do in our game:

We do NOT do this :
Code (ags) Select
player.Say("Nothing happens.");

Instead we do this :
Code (ags) Select
player.Say(SmartString("VER:1.1DATA:Nothing happens."));

The SmartString function is as follows :
Spoiler
Code (ags) Select
String SmartString(String s)
{
  String needle = "DATA:";
  int needlePos = s.IndexOf(needle);
  if (needlePos >= 0) {
    //Translate, then return the data
    s = GetTranslation(s);
    s = s.Substring(needlePos+needle.Length, s.Length-needle.Length);
  } else {
    String needle2 = "NEVERTRANSLATE:";
    int needlePos2 = s.IndexOf(needle2);
    if (needlePos2 >= 0) {
      //Return the data untranslated
      s = s.Substring(needlePos2+needle2.Length, s.Length-needle2.Length);
    }
  }
  return s;
}
[close]


So as you can see if lets you add as many special keywords or fields as you want in any String (VER is for the game version, NEVERTRANSLATE is to force the game not to translate that one, etc. And DATA is the actual text.)

This is useful for a few things. The main one being : You can spot (and sort) the newer lines directly by looking in your translations file. You can extend the capabilities to, for example, add which room this string is from, or a comment for the translator, or whatever you feel like.



Title: Re: Re-importing revised text into AGS after proofreading
Post by: Crimson Wizard on Wed 03/03/2021 10:33:09
Actually, the method suggested in discussions on other engines is to not put real text in game scripts at all, but instead put some keywords acting as IDs there (these may include real text or brief version of it as a hint for scripter).
Same may be applied to AGS, but you'll have to provide English translation (or whichever is your default) as TRA as well.

This gives 2 benefits:
* easier to deal with any text changes;
* possible to distinct multiple lines that look same in english but should be translated differently depending on context.
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Wed 03/03/2021 12:10:50
Mister OUXX : thanks for the suggestion of Smart Strings, it look amazing, and could be useful !

Crimson Wizard : if I understand well, you suggest that instead of putting real texts in scripts, you do like :

Tom name : "TOM"
Tom history : "I am a teenager and I like fruits"

I should do :

Tom name : "Tom name"
Tom history : "Tom history"

And then, create a translation file "ENGLISH" (for example) with :

Tom name
TOM
Tom history
I am a teenager and I like fruits

When the game is launching, it selects the translation ENGLISH and so the real text (in english) appears ?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Monsieur OUXX on Wed 03/03/2021 12:13:54
Quote from: Baguettator on Wed 03/03/2021 12:10:50
Crimson Wizard : if I understand well, you suggest...

Yes, that is what he suggests.
Usually the keys look like this : tom.name   tom.history    tom.history.title    tom.history.details   etc.

The reason we didn't go that way is for the reasons Crimson Wizard mentioned :
- You need an entire English translation file.
- It's easier to remember what the text is about if you see it directly in the source code, especially when designing dialogs.

Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Wed 03/03/2021 14:39:53
OK Monsieur OUXX, but with your Smart String, what about a text which is too long ? I mean like this :

String History=String.Format("blablabla[LOTS OF CHARACTERS THAT THE EDITOR CAN'T STORE IN ONE LINE] %s", "[THE END OF THE TEXT]");

It could be possible and easily readable with a SmartString function ?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Monsieur OUXX on Wed 03/03/2021 14:56:21
I'm not sure what kind of text you'd be writing that the Editor couldn't handle in one line! Unless you only mean that it doesn't fit in the window and you'd have to scroll horizontally. But then it's the same as with any other line of text. If you're worried about the capacity of the "string" variable type, then, again : What the hell are you trying to do?   ;-D ;-D ;-D

Forget about the SmartString thing, I didn't want to hijack the thread, just to give extra options.  ;-D
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Wed 03/03/2021 15:42:18
Well, sometimes, I have some texts that tell the story of a character, and that text will be used by a label (and the text of the label changes according to the selected character, it can't be a fixed text), and a story could take lots of letters, and there is a limit of 500 (the editor displays an error if the limit is over). So, I need the String.Format complex string  to have the full text.

Or maybe there is another way to do it ?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Monsieur OUXX on Sat 06/03/2021 19:40:00
I'm not sure exactly where the 500-characters limit lies (In the code editor itself, when writing a literal String? In the Display function? In Label.Text?) but either way the DATA stuff adds less than 10 characters, plus it's removed after it runs through the SmartString function. Plus you can still declare it in two strings and then display it in one. All in all : I'm confused by your theoretical problem. Let's leave it there, I think you got all the answers you needed by now regarding iterative enhancements of translations?
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Crimson Wizard on Sat 06/03/2021 23:31:48
Personally I use String.Append in that case, but Format is also a solution for this embarassing problem.
Anyhow, I guess you can translate parts of the message separately too, maybe mark in commentary that these are parts of a bigger message in case translation needs to say it differently (in a different order).
Title: Re: Re-importing revised text into AGS after proofreading
Post by: Baguettator on Mon 08/03/2021 09:28:33
Yes Monsieur OUXX, the limit of 500 characters is in the editor. You can't write a line of text (string of any kind I presume) over 500 characters. Is there any way to fix it or is it a limit that can't be removed ?

Crimson Wizard : yeah, String.Append is certainly a much better process for what I have to do ! Because it is easier to manipulate, and %s won't appear in the translation file, so it is less confusing... I will have some thought on that, maybe I will change my code. Thanks for the tip :)
Title: Re: Re-importing revised text into AGS after proofreading
Post by: eri0o on Mon 08/03/2021 16:22:44
I also use the String.Append method since it aligns things vertically. It would be useful to just write three ", like """ to start a multiline text and """ to close, but more often when I have this I notice it's either text that will work better being shorter or if it exists in a separate place.

I never tested but I am curious if this limit also applies to the dialog editor.

Recently I have been experimenting with the dialogs so I can separate text from game and use a switch inside the method I am using to override Say (e.g.: My day(this Character*, String message), to get different printing behaviors of the text depending on context.

Like having a cBook character so I can just Book: line to show things in a book. It's been pretty interesting.