Lazarus

Miscellaneous => Translations => Topic started by: Roland57 on November 27, 2021, 11:00:27 am

Title: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 11:00:27 am
Hello!

I use PO files for this project (https://gitlab.com/rchastain/mater/-/tree/master/gui). This is the first time I use PO files.

All my strings are correctly translated, excepted one which is always displayed in English.

The only difference that I can see with the other strings of the project is that this string has several lines, and that I use an included file.

Code: Pascal  [Select][+][-]
  1. (* aboutform.pas *)
  2. resourcestring
  3.   ReadMeText = {$I readme};
  4.   BTCloseCaption = 'Close';
  5.   FormCaption = 'About Mater GUI';

Code: Pascal  [Select][+][-]
  1. (* readme.pas *)
  2.   '' + LineEnding +
  3.   'Mater GUI %s' + LineEnding +
  4.   '' + LineEnding +
  5.   'Graphical user interface for Valentin Albillo''s mate searching program.' + LineEnding +
  6.   '' + LineEnding +
  7.   'Uses Chest by Heiner Marxen as auxiliary search engine.' + LineEnding +
  8.   '' + LineEnding +
  9.   'For Linux, uses Chest 3.19 (1). For Windows, uses WinChest by Heiner Marxen and Franz Huber (2).' + LineEnding +
  10.   '' + LineEnding +
  11.   '(1) http://turbotm.de/~heiner/Chess/chest.html' + LineEnding +
  12.   '(2) https://fhub.jimdofree.com'
  13.  

The included file is automatically generated from a .txt file that I edit by hand. That's why I do like that.

If someone who has more experience than I do with PO files would take a look, or has an idea why it doesn't work...

Regards.

Roland
Title: Re: One string not translated for unknown reason
Post by: Kays on November 27, 2021, 12:16:10 pm
The only difference that I can see with the other strings of the project is that this string has several lines, and that I use an included file.
If that was of any concern, you must see a difference if you substituted the {$I} with the file’s contents.

All my strings are correctly translated, excepted one which is always displayed in English.
I checked out what messages you got (https://gitlab.com/rchastain/mater/-/blob/master/gui/po/matergui.de.po) and noticed readMeText is the only message containing newlines. This might be the culprit of your problem, that the msgids don’t match because of different encoding of newlines.
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 12:31:13 pm
@Kays

Thank you for your answer.

I replaced "LineEnding" with "#10", and pasted the code directly in the file: the problem is still here.

Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 12:55:37 pm
You might want to have a look at this (http://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) 'official' doc on handling po strings. Do a Ctrl-F on 'remainder' and read on. However, I don't know if it's implemented with the Lazarus version of GetText as well. But worth a try.
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 04:18:29 pm
@Sieben

Thanks. I have read that page. I didn't find an explanation to my problem.
Title: Re: One string not translated for unknown reason
Post by: Fred vS on November 27, 2021, 04:39:55 pm
@Kays

Thank you for your answer.

I replaced "LineEnding" with "#10", and pasted the code directly in the file: the problem is still here.

Hello Roland.

Not sure if it helps but did you try with "#13" or "#10#13" ?

Fre;D
Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 04:43:51 pm
Just did a quick test, put a TLabel on a form, entered a two line caption and enabled i18n. Resulting po file had:

Code: Text  [Select][+][-]
  1. #: tfrmmain.label1.caption
  2. msgid ""
  3. "Line1\n"
  4. "Line2\n"
  5. msgstr ""

Translated this caption as:

Code: Text  [Select][+][-]
  1. #: tfrmmain.label1.caption
  2. msgid ""
  3. "Line1\n"
  4. "Line2\n"
  5. msgstr ""
  6. "Zeile1\n"
  7. "Zeile2\n"

included the po file like this (https://forum.lazarus.freepascal.org/index.php/topic,57203.0.html) and it worked. Which also answers the question if Lazarus has this implemented...

So just try \n for line endings.
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 04:56:41 pm
So just try \n for line endings.

Do you mean \n directly in my Pascal string? Otherwise I don't see what you mean.

My .po file looks like yours.

Code: Text  [Select][+][-]
  1. #: aboutform.readmetext
  2. msgctxt "aboutform.readmetext"
  3. msgid ""
  4. "\n"
  5. "Mater GUI %s\n"
  6. "\n"
  7. "Graphical user interface for Valentin Albillo's mate searching program.\n"
  8. "\n"
  9. "Uses Chest by Heiner Marxen as auxiliary search engine.\n"
  10. "\n"
  11. "For Linux, uses Chest 3.19 (1). For Windows, uses WinChest by Heiner Marxen and Franz Huber (2).\n"
  12. "\n"
  13. "(1) http://turbotm.de/~heiner/Chess/chest.html\n"
  14. "(2) https://fhub.jimdofree.com\n"
  15. msgstr ""
  16. "\n"
  17. "Mater GUI %s\n"
  18. "\n"
  19. "Interface graphique pour le programme de recherche de mat de Valentin Albillo.\n"
  20. "\n"
  21. "Utilise Chest de Heiner Marxen comme moteur de recherche auxiliaire.\n"
  22. "\n"
  23. "Pour Linux, Mater GUI utilise Chest 3.19 (1). Pour Windows, Mater GUI utilise WinChest de Heiner Marxen et Franz Huber (2).\n"
  24. "\n"
  25. "(1) http://turbotm.de/~heiner/Chess/chest.html\n"
  26. "(2) https://fhub.jimdofree.com\n"

By the way, I wonder why some messages have a "message context", while the other don't.

@Fred

Thanks, I will try.
Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 05:12:41 pm
What is aboutform.readmetext, a resourcestring or part of the lfm? What does it look like where it's defined?
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 05:28:34 pm
What is aboutform.readmetext, a resourcestring or part of the lfm? What does it look like where it's defined?

Please see the first message.  :)
Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 06:08:13 pm
Sorry, forgot about that...  :-[   But your setup works for me...?

Edith: including simple sample project, uses ResTrans (https://forum.lazarus.freepascal.org/index.php/topic,57203.0.html) package, however. Created with 2.0.10.


Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 06:30:25 pm
But your setup works for me...?

Weird. For me it doesn't work. But it is not so important after all.  :)
Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 06:35:39 pm
Just included a working sample project with my last message... you might want to check whether there are any differences with your actual setup.
Title: Re: One string not translated for unknown reason
Post by: Fred vS on November 27, 2021, 06:43:42 pm
Hello Roland.

Afaik, gettext does not like when msgid  begins with "":

Code: Pascal  [Select][+][-]
  1. msgctxt "aboutform.formcaption"
  2. msgid ""
  3. "Mater GUI %s\n"
  4. "\n"
  5.  

Just begin with this:

Code: Pascal  [Select][+][-]
  1. msgid "Mater GUI %s\n"
  2. "\n"

And also in the translated po file, add the original code in msgid "here original code"

Also in the readme, remove the first empty line.

Included update po files, here it (seems) to work.

PS: Maybe  :-[

Fre;D
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 06:45:28 pm
Just included a working sample project with my last message... you might want to check whether there are any differences with your actual setup.

Thanks. Your project works here. And I see no difference with mine until now. I will continue to search.
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 07:02:01 pm
Included update po files, here it (seems) to work.

Thank you for your help Fred. I am testing...
Title: Re: One string not translated for unknown reason
Post by: Sieben on November 27, 2021, 07:18:19 pm
Just one more idea: check whether the encoding of your po file still is UTF8. I seem to recall some weird effects if for some reason any editor might have mixed that up.
Title: Re: One string not translated for unknown reason
Post by: Fred vS on November 27, 2021, 07:21:15 pm
Hello Roland.

I am testing too and strangely, a mastergui.pot generated file is created with msgid "" at begin.

Strange.

Code: [Select]
msgid ""
"Mater GUI %s\n"
"\n"
"Graphical user interface for Valentin Albillo's mate searching program.\n"
"\n"
"Uses Chest by Heiner Marxen as auxiliary search engine.\n"
"\n"
"For Linux, uses Chest 3.19 (1). For Windows, uses WinChest by Heiner Marxen and Franz Huber (2).\n"
"\n"
"(1) http://turbotm.de/~heiner/Chess/chest.html\n"
"(2) https://fhub.jimdofree.com"
msgstr ""
Title: Re: One string not translated for unknown reason
Post by: wp on November 27, 2021, 07:22:55 pm
BTW, Roland, which Lazarus version are you on? I remember some changes in the help system regarding line endings some time ago.

[EDIT]
Using Laz/main I recreated the po files (Run/Build) and translated the aboutform.readmetext to German. When I copy the .de.mo file to the locale folder the text is still English, but when I copy the .de.po file I see my translation.
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 08:15:28 pm
When I copy the .de.mo file to the locale folder the text is still English, but when I copy the .de.po file I see my translation.

Yes, with the po files it works. Good point!

BTW, Roland, which Lazarus version are you on? I remember some changes in the help system regarding line endings some time ago.

It's v2.0.10.

Using Laz/main I recreated the po files (Run/Build) and translated the aboutform.readmetext to German.

May I have your German translation?   O:-)

@All
Thank you for your help.

Title: Re: One string not translated for unknown reason
Post by: wp on November 27, 2021, 09:21:53 pm
May I have your German translation?   O:-)
Here it is...
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 27, 2021, 09:31:37 pm
Here it is...

Danke schön.  :)
Title: Re: One string not translated for unknown reason
Post by: Roland57 on November 28, 2021, 08:19:53 am
@Sieben

So I see now why your sample project works: it also uses PO files.

I changed the project options, to save the PO files directly in locale folder, and no longer compile to MO. Problem solved.
TinyPortal © 2005-2018