Translating PCEM

Discussion of development and patch submission.
Post Reply
Neelix
Posts: 12
Joined: Tue 02 Jul, 2019 12:49 pm

Translating PCEM

Post by Neelix »

Hello,
I'm using PCEM for long time now. I wonder there's no translation. I would like to translate it to french, but there's no language files.

Where you interested for translations ?
How could I do ?
User avatar
gen_angry
Posts: 127
Joined: Sat 25 Feb, 2017 6:48 am

Re: Translating PCEM

Post by gen_angry »

From a cursory glance, it seems most of the strings throughout are hard-coded within the source itself so not an easy task.

How I would add translation support: you'd have to essentially create a class that would load a language file (like a giant JSON or what have you), put all of the strings from that file into a giant class of strings that would be read throughout the program. That way, any additional languages would just need a new JSON file with the proper fields. When you change languages, it would clear the class, load all the strings from new file, then redraw all UI elements. (The only reason I'd pick JSON is to use an easy-to-read way to allow people to add translations and I'm rather fond of it myself).

It's a bitch of a job and even more so when the code base is already made. You have to essentially go over every bit of the code, line by line, replacing every displayed string with a variable.

Sadly, if PCem was written in C# I could do it. I'm not comfortable enough with C/C++ to pull something like that off, especially on a long time established project like PCem.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: Translating PCEM

Post by shermanp »

Note that PCem is almost all C, with a few bits of C to C++ wrapping for the wxwidgets bit.

If one were to do translation stuff, it would probably be best to use the tools provided by wxWidgets for the job. See https://docs.wxwidgets.org/trunk/overview_i18n.html on the approach wxWidgets uses.
UPerschke
Posts: 72
Joined: Wed 25 May, 2016 7:43 pm

Re: Translating PCEM

Post by UPerschke »

Translations should be well thought of if you really want to go down that road.
It's not just the code changes to implement some kind of language file import.

Tom Scott once went on a rant about this worth watching imho: https://www.youtube.com/watch?v=0j74jcxSunY
Not sure though how much of his explainations do not relate to PCem.

It could be reasonable to look at other open source applications which use language files, e.g. 7-Zip, just to get some general ideas.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Translating PCEM

Post by SarahWalker »

Good video, though much of it doesn't seem applicable to PCem; we don't need to deal with names, thank god. The wxWidgets internationalisation page shermanp linked to looks useful as a starting point. Unfortunately a lot of PCem's GUI was ported from Win32 to wxWidgets using a wrapper (see wx-utils.cc), which will make life somewhat harder here.

But as gen_angry points out, the main starting point will be going through the code and extracting all strings. This shouldn't need a vast amount coding knowledge, move each user facing string out of the code and replace with some kind of identifier, possibly with a call to a 'wx_translate' function that would eventually call into wxGetTranslation but could initially just lookup an array of the existing English text. Any volunteers?
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: Translating PCEM

Post by shermanp »

Note, a lot of user facing strings will be in 'pc.xrc', although looking at the docs, I get the impression that strings here SHOULD be auto-translated if the resource is constructed correctly. Translation files are sill needed to actually translate of course...
JosepMa
Posts: 202
Joined: Tue 20 Jun, 2017 6:25 pm

Re: Translating PCEM

Post by JosepMa »

The extraction is done with tools, once you have identified what it needs to extract. That's what it explains when talking about the xgettext and _() Macro or wxGetTranslation.
That generates a file with the strings to translate.

The source code maintains the text there, and at runtime, the text is read and translated using the selected translation file, or kept in the original form if no translation is available for that one string. This part is done automatically by the toolkit.

There are online tools to help people translate these files then, even though a plain text editor or some translating apps that support the .po format can be used too.
Some examples of online collaborative translation sites are transifex.com and crowdin.com

I have helped translating several open source projects in those websites, but don't have experience with translating using wxWidgets. Only with QT (which works in a quite similar way from what I understand).
werther23
Posts: 1
Joined: Mon 10 Aug, 2020 1:09 pm

Re: Translating PCEM

Post by werther23 »

I don't know how easy it would be and what tools can be used for that, but I would happily help to translate PCem to brazilian portuguese.
Post Reply