Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation (German, French, Spanish, Italian...) #29

Open
Chelsea486MHz opened this issue Jul 20, 2021 · 5 comments
Open

Translation (German, French, Spanish, Italian...) #29

Chelsea486MHz opened this issue Jul 20, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Chelsea486MHz
Copy link
Member

Objective

Provide a German translation of the strings defined in headers/text.h.

Rationale

Users, especially in educative contexts, might want to use the software in their native language.

@Chelsea486MHz Chelsea486MHz added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jul 20, 2021
@Chelsea486MHz
Copy link
Member Author

Chelsea486MHz commented Jul 20, 2021

How should we go about it?

I was thinking about using a compilation-time flag (something like -DGERMAN) to select which strings to use from headers/text.h. It'd also be about time we rework the Makefile, but that's a whole new can of worms.

@brennennen
Copy link

brennennen commented Jul 21, 2021

In c land, folks usually use tools like "gettext" for internationalization.

Overview of the process:

You replace all your string declaration with a macro:

#ifdef USE_GETTEXT
   #define _(String) gettext (String)
#else
   // If no i18n, then process strings normally.
   #define _(String) String
#endif

Strings like the below:
#define TEXT_SIMSTART "Simulation started"
Would turn into:
#define TEXT_SIMSTART _("Simulation started")

Then you use the xgettext tool to grab all strings in your program and create a mapping template file (*.pot file).

Then you hand off this *.pot file to someone who knows the language you want to support. They use a po editor tool (it's a text file, so you can just edit it directly too) and export a *.po file back to you (files are named with the syntax "{lang}_{country}.po" with 2 characters for each. German spoken in Germany would be "de_DE.po" (de for Deutschland, and DE for Deutsche). You store this file in the source tree and distribute with the executable.

The gettext calls then look at the machines system language and use the po file to do string replacements. You can bypass the machines system language if you want too through some calls I don't remember.

As time goes on and you add/modify strings, you can also run xgettext commands to regrab all strings in your code and add them to your po file without removing the old ones, which you can then add translations for.

I think gettext can also fix number internationalization issues (commas vs periods, etc) too, but I've never touched that.

@Kastakin
Copy link

Kastakin commented Jul 22, 2021

My C is quite rusty but Italian is my first language and with my chemistry background I think I can help you with the Italian localization if we decide how to handle the translation process first.

@Chelsea486MHz
Copy link
Member Author

The gettext approach seems to be the best way to handle localisation! It clearly separates the "programming work" from the "translation work".

Unless other methods of similar efficiency come up, I think we can go ahead with this one.

If you'd like to submit an Italian translation alongside the switch to gettext, then have fun aha. I'll submit a French translation after yours

@gvmii
Copy link

gvmii commented Aug 8, 2022

I can help translate from English to Spanish, but I have literally 0 idea on C (I know about Python). I've worked in multiple translation projects. How can I proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants