How do the translation files actually work?

Discuss and coordinate development of mainline and user-made content translations.

Moderator: Forum Moderators

Post Reply
User avatar
Atreides
Posts: 344
Joined: March 30th, 2019, 10:38 pm
Location: A Nude Land

How do the translation files actually work?

Post by Atreides »

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
#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.
User avatar
octalot
Developer
Posts: 577
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: How do the translation files actually work?

Post by octalot »

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.
User avatar
Atreides
Posts: 344
Joined: March 30th, 2019, 10:38 pm
Location: A Nude Land

Re: How do the translation files actually work?

Post by Atreides »

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.
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... :-(

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!
gnombat
Posts: 366
Joined: June 10th, 2010, 8:49 pm

Re: How do the translation files actually work?

Post by gnombat »

Atreides wrote: April 23rd, 2021, 6:24 pm 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?
Any line beginning with the # character is only a comment - it will not affect the actual translation.
Atreides wrote: April 23rd, 2021, 6:24 pm 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...
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
User avatar
Atreides
Posts: 344
Joined: March 30th, 2019, 10:38 pm
Location: A Nude Land

Re: How do the translation files actually work?

Post by Atreides »

gnombat wrote: April 23rd, 2021, 10:11 pm
Atreides wrote: April 23rd, 2021, 6:24 pm 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?
Any line beginning with the # character is only a comment - it will not affect the actual translation.
Atreides wrote: April 23rd, 2021, 6:24 pm 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...
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
Thanks, I understand it fully now.
Post Reply