Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Is there a way to translate files on a CAT tool

A topic by rvkous created Apr 11, 2024 Views: 606 Replies: 16
Viewing posts 1 to 8

Hello it's me again with another question

None of the CAT tools I work with are able to read .lua files so I wanted to know if anyone else is going to translate using a CAT tool and if it's possible to convert the loc file into some format that can be read by these tools. I know .txt works but I'm wondering if it's possible to isolate the strings without losing formatting.

I hope this makes sense. Happy translating everyone!

(+3)

I'm sure others can pitch in with more details, but the general idea is to import the file as plain text, then use tagging/regex in order to exlude the non-translatable parts.



Thank you! I'll take a look

(1 edit) (+3)

The instructions above were a good hint/start, but didn’t work instantly. After fiddling a bit around I had it set up rather quickly in memoQ.

You can download the exported filter rule for memoQ from our server. Just unzip the file and import it in the Resource Manager thingy. (If you don’t trust random files from strangers, just open it with a text editor, it’s really just a text file.)

This setup will also keep the comments out of your translation as they felt a bit too generic to really help IMO. Note this isn’t a filter chain, so you’ll still have to escape both linebreaks as \n and ANSI double quotes as \" to avoid script errors.

(1 edit)

EDIT: it worked perfectly! thank youuuu

Thank you for the help and for sharing resources! I appreciate a lot

Thank you for this!!

Now that locjam is over I'm looking into how to do this and it worked! Thank you

I copy the text to an excel file for easier data manipulation, and from there it is pretty easy to extract the text between quotation marks (though the \" posed a bit of a challenge).

(2 edits) (+1)

Alternative for those with just Office and similar programs:

  • In a text editor like VS Code or Notepad++, that supports Search & Replace with regular expressions, look for the pattern ^(t\[\d+]\s+=)\s+(".*")\s+(--) and replace it with $1\t$2\t$3.
  • Delete all lines at the start of the file that start with -- (i.e. all the comment lines).
  • Open/import the file in your favorite spreadsheet editor (like Excel) and use Tab Separated Values (TSV) or TSV File as the file format.
  • You should see the translation in the second column.
  • No need to convert anything back, the file should run just fine.

Note this might screw with quotes in your text, so you should double-check them in a regular text editor once you’re done.

(+2)

Hi! Could you please point out where I went wrong?
The text editor didn't find any matches for the pattern ^(t[\d+]\s+=\s+")(.*)("\s+--), so I changed it to ^(t.[\d]+.\s+=\s+")(.*)("\s+--) which seemed to work (I by no means know what I'm doing when it comes to regex, so the issue probably lies here). I replaced the matches with $1\t$2\t$3 and converted the file to TSV.
However, when I opened it as a TSV in Excel, all the lines were in one long row (see the screenshot).
How do I fix this? Is there another regex pattern I could try?

Oops! Sorry, I wrote this from memory and actually didn’t try it! And it seems like it’s not interpreted the way I expected!

I have a tested method now and will update the instructions above in a moment.

(1 edit) (+1)

Updated the original post. The old regular expression didn’t work since the editor ate a \ at the start and \[t] means something different than [t].

You can do this replacement in two steps without regular expressions:

  • Replace all = " with =<tab>".
  • Replace all " --" with "<tab>--".

Then remove the lines at the start just like I mentioned above and it should work. (Does so for me in Excel.)

(+1)

The new regular expression still didn't work for me, but the two-step method did! Thank you very much for your help!

(+4)

And since I forgot adding it above, posting this standalone for visibility for those wanting to set up their filters manually:

Regex pattern before translatable text (i.e. start): ^t\[\d+] = "

Regex pattern after translatable text (i.e. end; mind the number of whitespaces!): " --

Regex pattern for translatable text (might be needed, e.g. in memoQ): .+

(+2)

For Trados users, I created a new file type based on regex-delimited text with these regex patterns:
Opening pattern: .*=\s"
Closing pattern: "\s.*$
(I didn't manage to include the comments as tags.)

(5 edits) (+1)

Thanks a lot for sharing this. In Trados I also managed to include the comments as non-translatable tags this way:

- Change the closing pattern of the file type to: $

- In "Inline tags" > "Add rule..." 

Rule type: Placeholder

with rule regex: "  --.*}

In Advanced... choose behavior as "Include".

(Note: it is the first time I try using inline tags generated by me, so please take this with a grain of salt! I am still in the middle of the translation, and while I tested exporting it and it seems to work fine, it might still fail somehow.)

Deleted 134 days ago
(+1)

I just turned it into a txt. file then opened it normally in Studio. Without doing anything more the "explanation" strings actually help in the file. Then you can either copy over the contents back into the original file or rename your translation file into a lua file. On the other hand, my game now shows a black screen, so maybe I'm not the best source for help. But to be fair, when working with the original zip file I can't even get it to upload without errors, so who knows.