How do the translation files actually work?
Moderator: Forum Moderators
- Atreides
- Posts: 1075
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
How do the translation files actually work?
When the .pot file is made it has a lot of extra stuff in there _other_ than the original text. Line numbers in particular. I was wondering if those line numbers are required? If the wml has a line deleted for example they will shift all of them by 1. Does this invalidate the .po file? I mean does it use those numbers to locate which text is to be translated or are the numbers actually just there for reference?
Second (bonus) question... if you were to put
at the top of a unit's file would it automatically be translated? That is... any strings in there that match anything from "mainline" such as sword and spear? I realize that anything that didn't exactly match mainline texts would never be translated.
Second (bonus) question... if you were to put
#textdomain wesnoth-units
at the top of a unit's file would it automatically be translated? That is... any strings in there that match anything from "mainline" such as sword and spear? I realize that anything that didn't exactly match mainline texts would never be translated.
Re: How do the translation files actually work?
The numbers are just there for reference. AFAIK the .pot files are part of the translation process, but are looked at by neither Wesnoth's integrated .po reader nor the .po to .mo compilation tool - once you've got a .po, changes to the .pot are only going to be noticed by the tools that update .po files and by the tool which calculates how complete the translations are.
In the .po files, along with the line numbers, there's sometimes a line that says
For your second question, see Reusing mainline translations.
In the .po files, along with the line numbers, there's sometimes a line that says
#, fuzzy
. Although it looks like a comment, it means that the next msgid / msgstr pair aren't used; it corresponds to poedit's "needs work" button. These lines can get generated by tools that update the .po file based on changes to the .pot file.For your second question, see Reusing mainline translations.
- Atreides
- Posts: 1075
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
Re: How do the translation files actually work?
Thanks! I had suspected this but needed clarification. I presume too that the # [attack] and such lines are also mere comments and that the only "active" elements of .po files are the msgid and msgstr lines? All the rest is just comments? That makes it MUCH easier. I was in terror that each time I edited a .cfg file I'd need to recreate a .pot file and merge it with the .po file to update the line numbers and other comments. Whew! In fact I was doing that... :-(octalot wrote: ↑April 23rd, 2021, 7:06 am The numbers are just there for reference. AFAIK the .pot files are part of the translation process, but are looked at by neither Wesnoth's integrated .po reader nor the .po to .mo compilation tool - once you've got a .po, changes to the .pot are only going to be noticed by the tools that update .po files and by the tool which calculates how complete the translations are.
In the .po files, along with the line numbers, there's sometimes a line that says#, fuzzy
. Although it looks like a comment, it means that the next msgid / msgstr pair aren't used; it corresponds to poedit's "needs work" button. These lines can get generated by tools that update the .po file based on changes to the .pot file.
For your second question, see Reusing mainline translations.
I already am using mainline-strings files. I was just thinking that one could do a quick and dirty superficial partial translation with an era by using the wesnoth-units textdomain instead of a custom one for the era. I understand that in order to fully translate an era's units with descriptions and all one MUST use a custom textdomain. I was thinking there was a lazy quick way to slam in just the common weapon names with the wesnoth-units textdomain. I guess it ought to work since line numbers don't matter!
Re: How do the translation files actually work?
Any line beginning with the
#
character is only a comment - it will not affect the actual translation.Note that you do, in fact, need to recreate the .pot file and merge it with the .po file(s) whenever you add a new translatable string - or edit an existing translatable string - in your .cfg files. (If you've edited the .cfg files but haven't made any additions or changes to the translatable strings, then it's not really necessary to update the .pot and .po files.)
If you do need to update your .po file(s), you will probably want to use the msgmerge tool. The following command will update the file
YOUR_TEXTDOMAIN.po
:Code: Select all
msgmerge --update YOUR_TEXTDOMAIN.po YOUR_TEXTDOMAIN.pot
- Atreides
- Posts: 1075
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
Re: How do the translation files actually work?
Thanks, I understand it fully now.gnombat wrote: ↑April 23rd, 2021, 10:11 pmAny line beginning with the#
character is only a comment - it will not affect the actual translation.
Note that you do, in fact, need to recreate the .pot file and merge it with the .po file(s) whenever you add a new translatable string - or edit an existing translatable string - in your .cfg files. (If you've edited the .cfg files but haven't made any additions or changes to the translatable strings, then it's not really necessary to update the .pot and .po files.)
If you do need to update your .po file(s), you will probably want to use the msgmerge tool. The following command will update the fileYOUR_TEXTDOMAIN.po
:
Code: Select all
msgmerge --update YOUR_TEXTDOMAIN.po YOUR_TEXTDOMAIN.pot