i18n improvements for units of measure#262
Conversation
Codecov Report
@@ Coverage Diff @@
## master #262 +/- ##
==========================================
- Coverage 45.90% 45.65% -0.25%
==========================================
Files 44 44
Lines 6915 6959 +44
==========================================
+ Hits 3174 3177 +3
- Misses 3741 3782 +41
Continue to review full report at Codecov.
|
|
Thanks for looking at this. I appreciate the effort and have been considering when we would need to use However, I do not think that the If you have time and the energy to look at it, you are welcome to take a stab at it as it will be a few days before I have time to sit down and code this. |
|
If we want to use native gettext, we should drop polib. I have added tests to hit all 4 message catalogs, so I can work on this. |
|
I think it will be easier to use |
|
I made a branch for this at https://github.com/singularity/singularity/tree/use-gettext-for-translations that on-the-fly compiles PO files into MO files and load them, in case you want to base your work on that. |
|
Thanks! I had already gotten to writing the MO someplace, but not to loading it yet. And I did go with polib in the end - We should think about packaging the files for release though instead of rewriting them every time the game starts. |
|
I have tested your branch and I'd prefer to stick to standards, creating a proper LC_MESSAGES directory for each locale to house the translations. This is what experiences translators expect. How about storing a shasum of the po files to check whether a mo file needs writing? Such an approach would also incur less writing to hard disk, which will extend the lifetimes of SSDs. |
…s the plural translations while saving the mo file
|
Well, we can forget about using polib. The Our best bet for updating the mo files from within the program is a subprocess call to the gettext library on the operating system. This will mean jumping through hoops if we're not on Linux. So, I guess we just have to bite the bullet and require from translators that they run the update script, and include the mo files in the packaging. |
|
Seems like polib is not the culprit. I deleted the plural strings from my translation file, ran Then I tried poedit in my Windows VM and have the same problem. |
|
Looks like the plural forms not showing in the .mo file is a display in Virtaal - it suddenly started working today with an .mo file generated out of Virtaal. I'll look into generating the files again now and then I'll need to change our calls for the data functions. @nthykier Do you know off the top of your head which functions added extra modifiers to the |
|
Great it started working. :) I have tried to fix all uses of |
|
Thanks! I have now gone through all the translatable strings that have a Next step will be to deal with all textdomains and hunt down any strings that need pluralization. |
|
FYI: I have "cherry-picked" some of your fixes to |
|
OK, some new problems:
|
|
I started the locale switching from scratch today and it's working now. The only thing that's still broken at this point is that it fails with the test suite, so I have to catch a missing key there. It's working fine though when I run the game. I don't like having special code just to make the test suite happy, that smells like a bug to me. try:
main_localedir = dirs.get_writable_file_in_dirs('locale', 'i18n')
except KeyError:
# Catch KeyError: 'i18n'
# Which happens with the test suite only
main_localedir = 'singularity/locale' |
|
Have you tried if you can reproduce the issue |
|
@nthykier Running |
nthykier
left a comment
There was a problem hiding this comment.
Generally looks good, but it needs a rebase before it can be merged (due to conflicts in merging).
So, I don't know where you are getting the conflicts from. I don't like rebasing branches with conflicts that have more than 1 commit in them, because I have to resolve the same conflict again and again as it steps through the commits. It's easier to just use the Squash option when merging. |
messages.pofor now, becausepgettextwill only become widely available with Python 3.8 and we need context for the data.Notes:
ngettextdoes not support floating point pluralspolibtogettext.gdbecause the resulting diff was quite big.If translators aren't available, I can source translations for languages I don't speak from https://unicode-org.github.io/cldr-staging/charts/37/summary/root.html