Discussion:
[Lazarus] Multilang application and syncing .po files
Tomáš Emresz via Lazarus
2018-06-19 11:09:28 UTC
Permalink
Hello,

i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.

Any idea ?
--
Tomáš Emresz
mailto:***@strankysnadno.cz


--
Carlos E. R. via Lazarus
2018-06-19 11:37:14 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
I'll answer as translator, I do not yet know how Lazarus handles this.

The programmer should only change the .pot files.

There are other tools that propagate the changes in the .pot to the .po files, which can be used by the programmer (in the Makefile) or the translators, using "msgmerge".

For example, a translator could do:

msgmerge --previous --no-wrap --force-po \
-U $POFILE -C ../memory.es.po $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo


The translator has access to previous translations and memory files to do fuzzy automatic translations which you probably as programmer can't.

The programmer could do:

msgmerge --previous --no-wrap --force-po -U $POFILE $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo

Notice the missing memory file


(and repeat for each language)



A sample script as programmer, for all languages:

#!/bin/bash

for FILES in `ls *.po` ;
do
echo
echo $FILES "-------------------------------------------------------------"
echo
F=`basename $FILES .po`
FF=`basename $F .es`
POFILE=$FF.es.po
POTFILE=../../00-pot/$FF.pot

if test -f $POFILE -a -f $POTFILE; then
echo Applying msgmerge to $POFILE
msgmerge --previous --no-wrap --force-po -U $POFILE $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo
else
echo "Not found: " $POFILE or $POTFILE
fi || { echo "msgmerge --no-wrap --force-po for \"$POTFILE\" failed" ; }

done


Of course, you'd have to adapt paths to your situation.
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Tomáš Emresz via Lazarus
2018-06-19 11:43:13 UTC
Permalink
Hello,

thanks for long answer, but - Lazarus generate only .po file ( and
.lrs in output directory). There is no .pot file.

T.E.
Post by Carlos E. R. via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
I'll answer as translator, I do not yet know how Lazarus handles this.
The programmer should only change the .pot files.
There are other tools that propagate the changes in the .pot to the
.po files, which can be used by the programmer (in the Makefile) or
the translators, using "msgmerge".
msgmerge --previous --no-wrap --force-po \
-U $POFILE -C ../memory.es.po $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo
The translator has access to previous translations and memory files
to do fuzzy automatic translations which you probably as programmer can't.
msgmerge --previous --no-wrap --force-po -U $POFILE $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo
Notice the missing memory file
(and repeat for each language)
#!/bin/bash
for FILES in `ls *.po` ;
do
echo
echo $FILES
"-------------------------------------------------------------"
echo
F=`basename $FILES .po`
FF=`basename $F .es`
POFILE=$FF.es.po
POTFILE=../../00-pot/$FF.pot
if test -f $POFILE -a -f $POTFILE; then
echo Applying msgmerge to $POFILE
msgmerge --previous --no-wrap --force-po -U $POFILE $POTFILE
msgfmt --check --stat $POFILE
rm messages.mo
else
echo "Not found: " $POFILE or $POTFILE
fi || { echo "msgmerge --no-wrap --force-po for \"$POTFILE\" failed" ; }
done
Of course, you'd have to adapt paths to your situation.
--
S pozdravem,
Tomáš Emresz
mailto:***@strankysnadno.cz


--
Maxim Ganetsky via Lazarus
2018-06-19 11:51:04 UTC
Permalink
Post by Carlos E. R. via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
I'll answer as translator, I do not yet know how Lazarus handles this.
The programmer should only change the .pot files.
Lazarus handles all this itself. Main .po file is actually is what you
mean by .pot (historically it has .po extension instead of .pot).
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Carlos E. R. via Lazarus
2018-06-19 12:12:54 UTC
Permalink
Post by Maxim Ganetsky via Lazarus
Post by Carlos E. R. via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
I'll answer as translator, I do not yet know how Lazarus handles this.
The programmer should only change the .pot files.
Lazarus handles all this itself. Main .po file is actually is what you
mean by .pot (historically it has .po extension instead of .pot).
Well, IMHO that is wrong.

The .pot file should contain all the messages without any translation,
it is the master file. And the .po files are the translations, one per
language. The .pot file is maintained by the programmers, the .po are
maintained by the translators.

Anyway, msgmerge can handle that situation, too.
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Zbyněk Fiala via Lazarus
2018-06-19 12:49:16 UTC
Permalink
Hello Tomáš,
I used this approach several times
https://github.com/alrieckert/lazarus/tree/master/examples/translation
and it worked.
For example here:
https://github.com/zbyna/Media-Stub-Kodi-Creator/blob/2373ec4ff24bf124cb244eab07772e3cc81bee47/unit1.pas#L22
https://github.com/zbyna/Media-Stub-Kodi-Creator/blob/master/unit1.pas#L214

Zbyněk
Post by Carlos E. R. via Lazarus
Post by Maxim Ganetsky via Lazarus
Post by Carlos E. R. via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
I'll answer as translator, I do not yet know how Lazarus handles this.
The programmer should only change the .pot files.
Lazarus handles all this itself. Main .po file is actually is what you
mean by .pot (historically it has .po extension instead of .pot).
Well, IMHO that is wrong.
The .pot file should contain all the messages without any translation,
it is the master file. And the .po files are the translations, one per
language. The .pot file is maintained by the programmers, the .po are
maintained by the translators.
Anyway, msgmerge can handle that situation, too.
--
Cheers / Saludos,
Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
--
_______________________________________________
Lazarus mailing list
https://lists.lazarus-ide.org/listinfo/lazarus
Maxim Ganetsky via Lazarus
2018-06-19 11:45:53 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
i have done generating .po files, could translate it through PoEdit,
but - when i add some RS or component, Lazarus update only main .po
file, not .cs.po etc. So could Lazarus update these files too, or is
there any merge tool for this ? Of course, I understand, that I must
translate this string after, but this time, I sync this files
manually, which is bad.
Any idea ?
Which Lazarus version, OS?

Lazarus does update translations together with main .po file. Make sure
that your antivirus does not block writing to them (look at dates/times
of translation files, if e.g. the half of them have the same date/time
after update and the others not, this is antivirus).

Note that you can sync translations with main .po file manually using
<lazarusdir>\tools\updatepofiles tool:

updatepofiles mainpofile.po
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Tomáš Emresz via Lazarus
2018-06-19 11:55:03 UTC
Permalink
This post might be inappropriate. Click to display it.
Maxim Ganetsky via Lazarus
2018-06-19 12:04:29 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
lazarus 1.8.5 (fixes)
Date : 2018-06-14
FPC: 3.0.5
SVN: 58067
i386-win32-win32/win63
Running on Windows 10 CZ Pro.
In some unit a have added LCLTranslator, setup i18n in project config
with right path, so components and resouceestrings
showed in po. When I add new, there is in main xxx.po file.
SetDefaultLang('','langs\');
in lpr on first line after begin.
Should I say Lazarus, that there is also xxx.cs.po (next will be
xxx.de.po etc) files or it should detect it in this directory ?
No, Lazarus will find all of them automatically.

Note that Lazarus will update translations only when main .po file is
changed (i.e. you made changes to resource strings in code). So in case
you place to your directory outdated translation when your main .po file
is already up to date, you should use updatepofiles tool, which will
update it.
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Tomáš Emresz via Lazarus
2018-06-19 13:26:03 UTC
Permalink
Hello,

i was searching for, changing something and I don't understand. When I
add force update po on next compile, change showed only in .cs.po
(main .po was not changed). When I add some resoucestrings to unit
(not form), this RS is not somewhere (I also tried force update .po).

Antivir is disabled.

tool updatepofiles (in other directory for test) did nothing (and
needs admin access (drive D, user could write in this directory).

T.E.
Post by Maxim Ganetsky via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
lazarus 1.8.5 (fixes)
Date : 2018-06-14
FPC: 3.0.5
SVN: 58067
i386-win32-win32/win63
Running on Windows 10 CZ Pro.
In some unit a have added LCLTranslator, setup i18n in project config
with right path, so components and resouceestrings
showed in po. When I add new, there is in main xxx.po file.
SetDefaultLang('','langs\');
in lpr on first line after begin.
Should I say Lazarus, that there is also xxx.cs.po (next will be
xxx.de.po etc) files or it should detect it in this directory ?
No, Lazarus will find all of them automatically.
Note that Lazarus will update translations only when main .po file is
changed (i.e. you made changes to resource strings in code). So in case
you place to your directory outdated translation when your main .po file
is already up to date, you should use updatepofiles tool, which will
update it.
--
Best regards,
--
S pozdravem,
Tomáš Emresz
mailto:***@strankysnadno.cz


--
Maxim Ganetsky via Lazarus
2018-06-19 14:14:01 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
i was searching for, changing something and I don't understand. When I
add force update po on next compile, change showed only in .cs.po
(main .po was not changed).
Therefore only .cs.po was outdated.
Post by Tomáš Emresz via Lazarus
When I add some resoucestrings to unit
(not form), this RS is not somewhere (I also tried force update .po).
Is this unit part of project? Please check in Project Inspector.
Post by Tomáš Emresz via Lazarus
Antivir is disabled.
tool updatepofiles (in other directory for test) did nothing (and
needs admin access (drive D, user could write in this directory).
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Tomáš Emresz via Lazarus
2018-06-19 18:07:09 UTC
Permalink
This post might be inappropriate. Click to display it.
Maxim Ganetsky via Lazarus
2018-06-19 22:33:42 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
Post by Maxim Ganetsky via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i was searching for, changing something and I don't understand. When I
add force update po on next compile, change showed only in .cs.po
(main .po was not changed).
Therefore only .cs.po was outdated.
Please, what do you exactly mean by this ? (in xxx.po there is no this
RS. This new RS was added only to xxx.cs.po but xxx.po was not changed
and is missing this RS)
This is plain impossible.
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Tomáš Emresz via Lazarus
2018-06-20 13:30:52 UTC
Permalink
Hello,

I have checked project inspector, and add some files to it. This time,
all is good, both files are updated as needs.

Other question is : is there any possibility to describe RS for
PoEdit, like if it is caption on some components ? Something like this
:

resourcestring
//Text when type of addres is Button
rsButton = 'Button';
//Text in list of types
rsListButton = 'Button';

?

Thanks
T.E.
Post by Maxim Ganetsky via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
Post by Maxim Ganetsky via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
i was searching for, changing something and I don't understand. When I
add force update po on next compile, change showed only in .cs.po
(main .po was not changed).
Therefore only .cs.po was outdated.
Please, what do you exactly mean by this ? (in xxx.po there is no this
RS. This new RS was added only to xxx.cs.po but xxx.po was not changed
and is missing this RS)
This is plain impossible.
--
Best regards,
--
S pozdravem,
Tomáš Emresz
mailto:***@strankysnadno.cz


--
Maxim Ganetsky via Lazarus
2018-06-20 14:24:50 UTC
Permalink
Post by Tomáš Emresz via Lazarus
Hello,
I have checked project inspector, and add some files to it. This time,
all is good, both files are updated as needs.
Good.
Post by Tomáš Emresz via Lazarus
Other question is : is there any possibility to describe RS for
PoEdit, like if it is caption on some components ? Something like this
resourcestring
//Text when type of addres is Button
rsButton = 'Button';
//Text in list of types
rsListButton = 'Button';
No, but you can use meaningful string identifier names, Poedit shows them.
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru
--
Tomáš Emresz via Lazarus
2018-06-20 14:28:15 UTC
Permalink
Hello,

thanks.

T.E.
Post by Maxim Ganetsky via Lazarus
Post by Tomáš Emresz via Lazarus
Hello,
I have checked project inspector, and add some files to it. This time,
all is good, both files are updated as needs.
Good.
Post by Tomáš Emresz via Lazarus
Other question is : is there any possibility to describe RS for
PoEdit, like if it is caption on some components ? Something like this
resourcestring
//Text when type of addres is Button
rsButton = 'Button';
//Text in list of types
rsListButton = 'Button';
No, but you can use meaningful string identifier names, Poedit shows them.
--
Best regards,
--
S pozdravem,
Tomáš Emresz
mailto:***@strankysnadno.cz


--
Loading...