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

Provide translation completeness metadata #5

Open
Vultraz opened this issue Feb 14, 2018 · 2 comments
Open

Provide translation completeness metadata #5

Vultraz opened this issue Feb 14, 2018 · 2 comments

Comments

@Vultraz
Copy link

Vultraz commented Feb 14, 2018

Is there any way to get the percentage complete of a given translation? Over in Wesnoth we're considering a build-time script that checks completeness and writes it to a metadata key in the repo (wesnoth/wesnoth#2466), but it occurs to me that Spirit Po might be able to do that itself at runtime. Is such a thing possible?

@cbeck88
Copy link
Owner

cbeck88 commented Feb 14, 2018

There's a few possible approaches:

One way you could do it right now is, just grab the hashmap from the spirit_po::catalog and scan over it yourself and check whether the translated string is empty. In case of plural messages, I guess you want to check whether any of the plural forms is empty?

The get_hashmap member function of spirit_po::catalog always lets you get the underlying hashmap.

I do it this way right now in the libintl vs. spirit_po validation tests here:

https://github.com/cbeck88/spirit-po/blob/master/test_libintl/main.cpp#L242

That's a bit awkward for you though since at least in theory, I might change the data structure that is used to represent a message in the catalog...

I think in reality, I'm not really going to do that, and you have my lib in your tree anyways. So its not like you are that vulnerable to compatibility problems if I change this, you just won't upgrade until you are ready. (I guess I can't really know what I might be forced to do in the future, but it seems really unlikely that I would be forced to make such a change at this point.)

A better thing I could do is provide an "is_complete" member function of the message object, similarly to how I provide is_plural, and then you could branch on that to determine whether a message is plural.

See is_plural here: https://github.com/cbeck88/spirit-po/blob/master/include/spirit_po/po_message.hpp#L35

and the related code comment.

Another thing I could do is do that, and also collect completion stats, in the catalog metadata.

It might also be cool if we can provide an accessor, beyond what libintl does, so that you can query if a particular string is actually translated, and give WML people a warning or something if an untranslated string actually appears in their campaign. (Wesnoth could make that that optional or something I guess?)

Idk, what do you think is best?

@singalen
Copy link

I'm afraid calculating translation% would be very CPU-intensive, no matter what approach is taken.
It means parsing 300M of pos or 100M of mos.

While 99.99% of the times the user only needs 1 out of 58 translations.

We might cache the results, of course...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants