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

Switch to Gettext (PO) file format for client-side translations #7290

Open
Wuzzy2 opened this issue May 1, 2018 · 21 comments · May be fixed by #14726
Open

Switch to Gettext (PO) file format for client-side translations #7290

Wuzzy2 opened this issue May 1, 2018 · 21 comments · May be fixed by #14726
Labels
@ Client / Audiovisuals Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible). @ Translation

Comments

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented May 1, 2018

Issue type
  • Feature request
Summary

I propose to switch to PO format for client-side / mod translations and remove all traces of the weird Minetest-only .tr file format.

Rationale

Seriously, this should be a no-brainer.

  • Minetest itself already uses Gettext and PO files for all engine-related stuff. Giving mods special treatment and a different file format is unjustified and clunky
  • The Gettext toolchain for dealing with and updating PO files provided by Gettext is lightyears ahead of what Minetest could ever reasonably offer
  • As of now, Minetest still does not offer ANY toolchain for updating the .tr files. Something as seemingly trivial such as updating a .tr file would be a nightmare
  • PO is very widespread and many translators are comfortable with it. .tr is Minetest-only and obscure; few people want to learn a new file format for no real reason
  • Many online translation websites support the PO format, including Weblate, which is used for Minetest itself
  • PO supports plural forms
  • The .tr format is Minetest-only, so interoperability with existing tools is practically zero
Thoughs about compability

Note that there's no official release yet with mod translations, so it is not be too late to make the switch, you do not have to worry about breaking existing translations yet. If you wait with this for AFTER the 0.5.0 release, a transition would likely to be more painful.

@sfan5
Copy link
Member

sfan5 commented May 1, 2018

Giving mods special treatment and a different file format is unjustified and clunky

It seems you did not inform yourself about why a custom file format was chosen instead of gettext.

Additionally (quote):

In case you have a solution that allows to load dynamically gettext po files (and unload them again once one leaves the server), then I will switch to gettext asap. Without it, I can find no better way than having to recode gettext, which is way more complicated than what we currently have.

Do you have such a solution?

Don't get me wrong, there are good reasons to switch to the widely used .po format, but it's not as easy as it sounds.

@sfan5 sfan5 added @ Client / Audiovisuals Feature request Issues that request the addition or enhancement of a feature @ Translation labels May 1, 2018
@paramat paramat added the Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible). label May 1, 2018
@ghost
Copy link

ghost commented May 1, 2018

Why not simply use PO files instead of compiled MO files and Gettext?

So both sides can have what they most want: Everyone creating mods and/or translations can have a super stable, widespread, and reliable toolchain and you devs can have weird plaintext parsing you seem to have a fetish for.

@sfan5
Copy link
Member

sfan5 commented May 1, 2018

Nobody wants plaintext parsing, it's just that gettext does not expose the mechanisms needed to make it work for client-side translations.

Besides, parsing .po files is not enough. To get all gettext features such as plural handling you do need to reimplement gettext, which is -- as nore already said -- complicated.

@ghost
Copy link

ghost commented May 1, 2018

Nobody wants plaintext parsing

Then all the plaintext parsing that happens in Minetest is there because …?

Besides, parsing .po files is not enough. To get all gettext features such as plural handling you do need to reimplement gettext, which is -- as nore already said -- complicated.

Then don’t replicate Gettext 1:1 but instead use the superior format and toolchain to get a PO file that then is used by the translation system instead of the stupid TR files that have no toolchain at all.

To me it’s not about the actual implementation but the workflow when translating stuff. And this is – of course – Gettext based because every more or less relevant project uses Gettext.

There are dozens and hundreds of tools, web services, and systems to get the untranslated strings, translate them, and return something (a PO file) that can be processed further (usually it is compiled to MO and then be used by Gettext, but that does not HAVE to be like that, the PO file can be used everywhere else).

@sfan5
Copy link
Member

sfan5 commented May 1, 2018

Then all the plaintext parsing that happens in Minetest is there because …?

Go back to the forum post I linked above and read it again.

Then don’t replicate Gettext 1:1

????????

instead use the superior format and toolchain to get a PO file that then [...]

Yes I'm talking about that, doing that is complicated.

I'll say it again just in case: I am in favour of switching to gettext, but it's not easily possible at the moment.

@ghost
Copy link

ghost commented May 1, 2018

Go back to the forum post I linked above and read it again.

You mean the part that basically reads “we use the format intlib once used before they switched to use PO files – but we don’t do that”?

And why cobble together and own weird system and not simply implement intlib?

????????

!!!!!!!!

Yes I'm talking about that, doing that is complicated.

Why exactly is parsing a PO file complicated? There are even parsers for the compiled MO files in plain Lua.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented May 1, 2018

Can you please give a rough overview on how the client-side translations work in terms of network packets being exchanged between client and server?

I want to understand why there's a problem/difficulty.

@sfan5
Copy link
Member

sfan5 commented May 1, 2018

You mean the part [...]?

No, I mean the part that says "gettext can't dynamically load and unload translations so we were forced to come up with our own system".

Why exactly is parsing a PO file complicated?

That's not what I said.
It's not, the complicated part is when you want to be 100% compatible to gettext (e.g. plural forms). Now if you only want similar functionaliry to intllib, that is doable.

Can you please give a rough overview on how the client-side translations work in terms of network packets being exchanged between client and server?

The gist of it is (for specifics ask nore):

  • server sends translation files alongside media
  • client loads the ones with correct language on startup
  • when a translated string is found, the client looks it up (does substitution, etc.) and replaces it

I want to understand why there's a problem/difficulty.

The difficulty is not in the network protocol or what is sent to the client.
The difficulty is with what libgettext allows us to do, namely it can't (un-)load translations at runtime.

@ghost
Copy link

ghost commented May 2, 2018

No, I mean the part that says "gettext can't dynamically load and unload translations so we were forced to come up with our own system".

Dude, you missed my whole point.

DO. NOT. USE. GETTEXT. ... Can't write it any clearer than that.

Use the PO file format so people can use their usual translation toolchain and do whatever is needed in order to provide translations as wanted.

@sfan5
Copy link
Member

sfan5 commented May 2, 2018

I thought the whole point of this issue is that Wuzzy wanted gettext (the software) to be used.
In any case, supporting gettext (the file format) essentially requires re-implementing gettext, which is non-trivial and complicated.

@ghost
Copy link

ghost commented May 2, 2018

I thought the whole point of this issue is that Wuzzy wanted gettext (the software) to be used.

Yes, but since Gettext can't be used easily it would be a good starting point to use plain PO files at least so the toolchain on user side (mod developers, translators, etc.) doesn't change.

In any case, supporting gettext (the file format) essentially requires re-implementing gettext

Then don't support 90 percent of the features then. Just plain strings with replacement variables. It is so inherently simple that even I was able to do it in plain Lua.

https://github.com/4w/xtend/tree/master/xtend_default/tools/convert_po_file_to_tr_file

But because of my Lua skills and willingness to completely dig into something stupid as this it does not support multi-line strings.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented May 2, 2018

Yeah, I only care about adopting the PO file format, not about the exact implementation in Minetest.

@Ekdohibs
Copy link
Member

Ekdohibs commented May 3, 2018

I just found about this old (2007) code for parsing MO files: http://number-none.com/blow/code/mo_file/
I don't know whether it still works with the current gettext, but if it does, it would probably solve the current problems.

@rubenwardy
Copy link
Member

How easy would it be to modify gettext to expose or extract their file parser?

@codexp
Copy link

codexp commented Jun 25, 2018

I couldn't make any sense of this thread here. There is something I might be missing in my understanding.
As for now I know intllib is implemented in many mods and it works, works as good as the former text translation (both lacking for dynamic loading).

Is it maybe the future plans to implement dynamic translation loading in future versions of minetest?
Which would be implemented with old format (because PO parsing is complicated?).

@sfan5
Copy link
Member

sfan5 commented Jun 25, 2018

works as good as the former text translation

Works in the sense that a single language is forced on every single client on the server, yes.

dynamic translation loading

Suppose you join a server, it provides translation files for a certain mod, then you leave and join another server, which happens to provide a translation file for the same mod, but a different one.
Minetest needs to be able to unload the first translations after you leave, libgettext does not allow us to do this, which is why we aren't using it.

@codexp
Copy link

codexp commented Jun 25, 2018

is it possible to sandbox libgettext to be able to reload it?

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented Jun 26, 2018

So basically to make this work, you actually have to write your own PO parser?
Ouch, now I understand why you are annoyed by this.

Maybe talk to the Gettext people about this. I still can't wrap my head around that you supposedly cannot unload catalogues.

@Ekdohibs
Copy link
Member

Ekdohibs commented Jun 26, 2018

Minetest needs to be able to unload the first translations after you leave, libgettext does not allow us to do this, which is why we aren't using it.

Besides, it seems like the other thing we need to do, loading translation files at runtime, is not possible either.

@codexp
Copy link

codexp commented Jun 29, 2018

Is it possible to add basic support for PO files (without fancy features)?
So that it would be used same way as text files, but give developers/translators the chance to use the mighty toolchain ^^

This will require a very basic loader for PO files.

@numberZero
Copy link
Contributor

Is it possible to add basic support for PO files

inttlib does exactly that.

@paramat paramat added the Concept approved Approved by a core dev: PRs welcomed! label Jun 10, 2019
@rubenwardy rubenwardy changed the title Switch to PO file format for client-side translations Switch to Gettext (PO) file format for client-side translations May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Audiovisuals Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible). @ Translation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants