Recent

Author Topic: One string not translated for unknown reason  (Read 9110 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 310
One string not translated for unknown reason
« on: November 27, 2021, 11:00:27 am »
Hello!

I use PO files for this project. 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
« Last Edit: November 27, 2021, 11:07:57 am by Roland57 »

Kays

  • Sr. Member
  • ****
  • Posts: 444
  • Whasup!?
    • KaiBurghardt.de
Re: One string not translated for unknown reason
« Reply #1 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 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.
Yours Sincerely
Kai Burghardt

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #2 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.


Sieben

  • Sr. Member
  • ****
  • Posts: 302
Re: One string not translated for unknown reason
« Reply #3 on: November 27, 2021, 12:55:37 pm »
You might want to have a look at this '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.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #4 on: November 27, 2021, 04:18:29 pm »
@Sieben

Thanks. I have read that page. I didn't find an explanation to my problem.

Fred vS

  • Hero Member
  • *****
  • Posts: 2726
    • StrumPract is the musicians best friend
Re: One string not translated for unknown reason
« Reply #5 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
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Sieben

  • Sr. Member
  • ****
  • Posts: 302
Re: One string not translated for unknown reason
« Reply #6 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 and it worked. Which also answers the question if Lazarus has this implemented...

So just try \n for line endings.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #7 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.
« Last Edit: November 27, 2021, 05:16:23 pm by Roland57 »

Sieben

  • Sr. Member
  • ****
  • Posts: 302
Re: One string not translated for unknown reason
« Reply #8 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?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #9 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.  :)

Sieben

  • Sr. Member
  • ****
  • Posts: 302
Re: One string not translated for unknown reason
« Reply #10 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 package, however. Created with 2.0.10.


« Last Edit: November 27, 2021, 06:32:38 pm by Sieben »
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #11 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.  :)

Sieben

  • Sr. Member
  • ****
  • Posts: 302
Re: One string not translated for unknown reason
« Reply #12 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.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Fred vS

  • Hero Member
  • *****
  • Posts: 2726
    • StrumPract is the musicians best friend
Re: One string not translated for unknown reason
« Reply #13 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
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: One string not translated for unknown reason
« Reply #14 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.

 

TinyPortal © 2005-2018