gettext and define
Moderator: Forum Moderators
gettext and define
Hello,
I don't know if I am in the good subject. If not, thank you to move this post.
I am trying to translate a user's campaign. I use PoEdit and wmlxgettext, like everybody, to prepare my .pot file. But.......
Many unit's definitions use many "#define" and, if the opening tag [unit_type] is in the unit's file, the closing tags [/unit_type] is in the include. So wmlxgettext refuse to give me the original messages and stop on error, doing nothing.
I think that I am not the first to have this kind of problem.
Is somebody knowing a "pre-processor" which could give me a "result file" with the #define included ? Maybe a part of the official loader of the game ?
As I did not write programs from very long time, maybe 10 or 15 years, if I try to write it I will loose at least 2 or 3 weeks.
As may grand-mother said : Better 1 who knows than 2 who search.
Thank you for your help.
I don't know if I am in the good subject. If not, thank you to move this post.
I am trying to translate a user's campaign. I use PoEdit and wmlxgettext, like everybody, to prepare my .pot file. But.......
Many unit's definitions use many "#define" and, if the opening tag [unit_type] is in the unit's file, the closing tags [/unit_type] is in the include. So wmlxgettext refuse to give me the original messages and stop on error, doing nothing.
I think that I am not the first to have this kind of problem.
Is somebody knowing a "pre-processor" which could give me a "result file" with the #define included ? Maybe a part of the official loader of the game ?
As I did not write programs from very long time, maybe 10 or 15 years, if I try to write it I will loose at least 2 or 3 weeks.
As may grand-mother said : Better 1 who knows than 2 who search.
Thank you for your help.
Celui qui dans la vie, est parti de zéro pour n'arriver à rien dans l'existence n'a de merci à dire à personne.
Pierre Dac
Pierre Dac
Re: gettext and define
I immediately noticed your problem when I read this subject
I had suspected that the current version of wmlxgettext cannot handle WML sources which have some macros, same as the old perl version.
I'm not sure this is what you want, but I have a modified wmlxgettext. Its original version was included in 1.12.1, and written by perl.
I simply modified it to ignore errors. Maybe I also corrected some problems but I don't remember them.
It can create a pot file of LotI.
I had suspected that the current version of wmlxgettext cannot handle WML sources which have some macros, same as the old perl version.
I'm not sure this is what you want, but I have a modified wmlxgettext. Its original version was included in 1.12.1, and written by perl.
I simply modified it to ignore errors. Maybe I also corrected some problems but I don't remember them.
It can create a pot file of LotI.
- Attachments
-
- wmlxgettext.zip
- (3.9 KiB) Downloaded 526 times
Re: gettext and define
Method 1: Use the --preprocess option to wesnoth, for example to output to a directory called "temp"
Code: Select all
wesnoth --preprocess Defense_of_Elensefar temp --preprocess-defines CAMPAIGN_DEFENSE_OF_ELENSEFAR,HARD
Re: gettext and define
Hello,
Thank you for your answers and also for your speed.
I will try the two methods.
The oooo method seems good to see what must be done to play.
The octalot methods better to see what is really done when you play.
Thank you for your answers and also for your speed.
I will try the two methods.
The oooo method seems good to see what must be done to play.
The octalot methods better to see what is really done when you play.
Celui qui dans la vie, est parti de zéro pour n'arriver à rien dans l'existence n'a de merci à dire à personne.
Pierre Dac
Pierre Dac
Re: gettext and define
Hello,
Last news from the front :
The wmlxgettext from oooo work very fine. But...... Not for the lua files.
So I used the new to create a "special" file and merged it with the main.
Now I hope that I have really ALL the sentences.
Have a good night.
Last news from the front :
The wmlxgettext from oooo work very fine. But...... Not for the lua files.
So I used the new to create a "special" file and merged it with the main.
Now I hope that I have really ALL the sentences.
Have a good night.
Celui qui dans la vie, est parti de zéro pour n'arriver à rien dans l'existence n'a de merci à dire à personne.
Pierre Dac
Pierre Dac
Re: gettext and define
Uhm, It seems to work fine to me, but I'm not quite sure because I recently don't play LotI.
I use the wmlxgettext with following command line which specifies all cfg and lua files explicitly.
Code: Select all
wmlxgettext --directory $DIR --domain $DOM --initialdomain $DOM `cd $DIR && find -name '*.cfg' -o -name '*.lua' | sort`
Re: gettext and define
Hello,
No matter, I wrote a little shell script (only 4 lines with the #! /bin/sh) with a 'msgcat' and all is done.
It was just a
Thank you again for your help.
Have a good day or night wherever you are.
No matter, I wrote a little shell script (only 4 lines with the #! /bin/sh) with a 'msgcat' and all is done.
It was just a
Thank you again for your help.
Have a good day or night wherever you are.
Celui qui dans la vie, est parti de zéro pour n'arriver à rien dans l'existence n'a de merci à dire à personne.
Pierre Dac
Pierre Dac
Re: gettext and define
Sorry, I am very late since I am not used to read a lot the wesnoth forum. I am the main developer and mantainer of the python wmlxgettex.
Wmlxgettext cannot parse macros.
Wmlxgettext reads WML and lua through regular expressions. This means that implementing a macro parser inside the code is very hard, error-prone and can introduce bugs. So I drop out the idea of parsing Macros.
The commented [/unit_type] will be parsed by wmlxgettext like an actual closing tag thank of the magic world "wmlxgettext" which will say that the following text must be parsed like an actual WML code. So, in your use case, you could write a code like this one:
Here the doc page about the "# wmlxgettext" special comment, for a deeper explaination (in the example showed by the docs there is a closing tag without an opening one. In your situation you will simply apply the opposite case, but the logic is the same).
Ignoring errors, instead, is a bad solution. You can introduce issues that are not immediately visible which possibly makes your .pot file bugged (if not completely wrong and not working). So I would highly discourage to use that custom edit of perl wmlxgettext posted before, where error checking was eradicated.
I would suggest you to read the Wmlxgettext Documentation for End-Users which can clarify a lot of doubts, including this one. However if you have other questions or doubts related to wmlxgettext usage you can ask here and I will be happy to answer.
Wmlxgettext cannot parse macros.
Wmlxgettext reads WML and lua through regular expressions. This means that implementing a macro parser inside the code is very hard, error-prone and can introduce bugs. So I drop out the idea of parsing Macros.
This is absolutely normal. When the tag is closed inside a macro, the issue can be solved using a dedicated comment # wmlxgettextMany unit's definitions use many "#define" and, if the opening tag [unit_type] is in the unit's file, the closing tags [/unit_type] is in the include. So wmlxgettext refuse to give me the original messages and stop on error, doing nothing.
Code: Select all
# wmlxgettext: [/unit_type]
Code: Select all
[unit_type]
{MY_MACRO_WHICH_CONTAIN_CLOSING_TAG}
# wmlxgettext: [/unit_type]
Ignoring errors, instead, is a bad solution. You can introduce issues that are not immediately visible which possibly makes your .pot file bugged (if not completely wrong and not working). So I would highly discourage to use that custom edit of perl wmlxgettext posted before, where error checking was eradicated.
I would suggest you to read the Wmlxgettext Documentation for End-Users which can clarify a lot of doubts, including this one. However if you have other questions or doubts related to wmlxgettext usage you can ask here and I will be happy to answer.
Re: gettext and define
Hi, do you know if by changing the po files and re building the game, those changes will be added to the game? For examples if we add translations that are missing in One language, thanks a lot for any advice!
Re: gettext and define
It should. Alternatively, you can use a tool like PoEdit or Virtaal to generate an mo file and stick it in the correct directory.
See https://wiki.wesnoth.org/GettextForTranslators
See https://wiki.wesnoth.org/GettextForTranslators
Re: gettext and define
Hello.
I have created some pots using wmlxgettext (for python3 ver= 2019.09.03.py3) included in the wesnoth package.
Currently, the specification seems to be that the root directory of each addon is scanned last.
However, many of the add-on pots seem to be scanned the root first. (e.g. _main.cfg seems to be scanned first).
Line 9 of autof.py, which comes with the current wmlxgettext, looks like this
If this last "False" is set to "True", the scan will start from the root.
I am not skilled enough to determine if there is any inconvenience in setting it to True, but if there is not, I would like to change it to True and run it.
Please let me know your opinion.
I have created some pots using wmlxgettext (for python3 ver= 2019.09.03.py3) included in the wesnoth package.
Currently, the specification seems to be that the root directory of each addon is scanned last.
However, many of the add-on pots seem to be scanned the root first. (e.g. _main.cfg seems to be scanned first).
Line 9 of autof.py, which comes with the current wmlxgettext, looks like this
Code: Select all
for root, dirs, files in os.walk(pathdir, topdown=False):
I am not skilled enough to determine if there is any inconvenience in setting it to True, but if there is not, I would like to change it to True and run it.
Please let me know your opinion.
-------
chee / k.k
chee / k.k
Re: gettext and define
Thank you for the guidance.
I seem to have been running a version of wmlxgettext before that discussion took place.
Using wmlxgetext, which comes with BfW 1.16.6, I have confirmed that the new options had been added. ( "--no-sort-by-file" )
By the way, this string of version would be better updated. It is one of the reasons for my misunderstanding.
Anyway, thank you very much.
Code: Select all
parser.add_argument(
'--version',
action='version',
version='wmlxgettext 2019.09.03.py3'
-------
chee / k.k
chee / k.k