[Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
Currently I am porting the component TMoon to Lazarus (https://github.com/Ahoerstemeier/delphimoon). A goal is to be able to compile package and demo with Lazarus AND Delphi. The original demo is a multi-language application which achieves translation using resource strings in a (I guess) Delphi1-like, windows-specific way. Using the Lazarus system of po files really is very easy and much more versatile compared to that. But now I am faced with the problem how to bring this back into the Delphi version. I know that the Lazarus translation system is based on gnugettext. I can add the unit gnugettext to the Delphi project. But how to continue? The original gnugettext requires the language to be specified as the name of a subfolder between "locale" and "LC_MESSAGES" (e.g., "locale/de/LC_MESSAGES/default.mo" for German), but Lazarus puts the language code into the po/mo file name (e.g., "project.de.po"). And I also don't get the point how to switch languages at runtime. Does anybody have experience with a similar project? I mean: how to use the po files for both Lazarus and Delphi. BTW: Working with the i18n options again I noticed that there are now two boxes "Excluded" > "Identifiers", "Originals" in the i18n project options. What can be put in there? Which effect does it have? Does it solve the issue that the same strings enter the po files again and again? Werner -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
26.01.2018 12:54, Werner Pamler via Lazarus пишет: > Currently I am porting the component TMoon to Lazarus > (https://github.com/Ahoerstemeier/delphimoon). A goal is to be able to > compile package and demo with Lazarus AND Delphi. The original demo is a > multi-language application which achieves translation using resource > strings in a (I guess) Delphi1-like, windows-specific way. Using the > Lazarus system of po files really is very easy and much more versatile > compared to that. > > But now I am faced with the problem how to bring this back into the > Delphi version. I know that the Lazarus translation system is based on > gnugettext. I can add the unit gnugettext to the Delphi project. But how > to continue? The original gnugettext requires the language to be > specified as the name of a subfolder between "locale" and "LC_MESSAGES" > (e.g., "locale/de/LC_MESSAGES/default.mo" for German), but Lazarus puts > the language code into the po/mo file name (e.g., "project.de.po"). And > I also don't get the point how to switch languages at runtime. Maybe you can use adapted copies of translations.pas unit (from LazUtils) and lcltranslator.pas unit (from LCL). They will need to be ported for Delphi, though. > Does anybody have experience with a similar project? I mean: how to use > the po files for both Lazarus and Delphi. > > BTW: Working with the i18n options again I noticed that there are now > two boxes "Excluded" > "Identifiers", "Originals" in the i18n project > options. What can be put in there? Which effect does it have? Does it > solve the issue that the same strings enter the po files again and again? PO file consists of entries. Each entry consists of (at least) identifier name, original string value and translated string value. By default IDE collects all captions from components on form. If you use resource strings for translation at the same time you may want in some cases to filter some strings. For example, you have a form with caption 'Form1' and with some labels in it. Then you translate this caption via resource string and all labels by IDE means. In this case you will have in PO file 'Form1' entry and entry for resource string which effectively replaces it. Obviously you don't want to burden translators with 'Form1' entry. That is where the filters are useful. -- Best regards, Maxim Ganetsky mailto:gan...@narod.ru -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
Am 26.01.2018 um 11:33 schrieb Maxim Ganetsky via Lazarus: 26.01.2018 12:54, Werner Pamler via Lazarus пишет: Maybe you can use adapted copies of translations.pas unit (from LazUtils) and lcltranslator.pas unit (from LCL). They will need to be ported for Delphi, though. Hmm... A lot of work for just a demo. No other way? Can't gnugettext be configured to use the Lazarus structure? BTW: Working with the i18n options again I noticed that there are now two boxes "Excluded" > "Identifiers", "Originals" in the i18n project options. What can be put in there? Which effect does it have? Does it solve the issue that the same strings enter the po files again and again? PO file consists of entries. Each entry consists of (at least) identifier name, original string value and translated string value. By default IDE collects all captions from components on form. If you use resource strings for translation at the same time you may want in some cases to filter some strings. For example, you have a form with caption 'Form1' and with some labels in it. Then you translate this caption via resource string and all labels by IDE means. In this case you will have in PO file 'Form1' entry and entry for resource string which effectively replaces it. Obviously you don't want to burden translators with 'Form1' entry. That is where the filters are useful. Thanks for the explanation. It motivated me to play with these two boxes: If I don't want to have the auto-generated entry 'Form1' to be in the po file I must enter this string in the box "Originals". Alternatively I can use the identifier of the caption in the box "identifiers" - it must be entered in the po syntax: "tform1.caption", or "tform1.button1.caption" for a button named TButton. What was confusing me is that the ignored entries remain in the master po and translated po files after these modifications. Only after "Clean up and Build" they do disappear. This, however, takes a long time because all required units are recompiled. Wouldn't it be better to have a menu command "Clean po file" which just rebuilds the rsj and po files? -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
26.01.2018 14:05, Werner Pamler via Lazarus пишет: > > Am 26.01.2018 um 11:33 schrieb Maxim Ganetsky via Lazarus: >> 26.01.2018 12:54, Werner Pamler via Lazarus пишет: >> Maybe you can use adapted copies of translations.pas unit (from >> LazUtils) and lcltranslator.pas unit (from LCL). They will need to be >> ported for Delphi, though. > > Hmm... A lot of work for just a demo. No other way? Can't gnugettext be > configured to use the Lazarus structure? Don't know, TBH. >>> BTW: Working with the i18n options again I noticed that there are now >>> two boxes "Excluded" > "Identifiers", "Originals" in the i18n project >>> options. What can be put in there? Which effect does it have? Does it >>> solve the issue that the same strings enter the po files again and >>> again? >> PO file consists of entries. Each entry consists of (at least) >> identifier name, original string value and translated string value. By >> default IDE collects all captions from components on form. If you use >> resource strings for translation at the same time you may want in some >> cases to filter some strings. >> >> For example, you have a form with caption 'Form1' and with some labels >> in it. Then you translate this caption via resource string and all >> labels by IDE means. In this case you will have in PO file 'Form1' entry >> and entry for resource string which effectively replaces it. Obviously >> you don't want to burden translators with 'Form1' entry. That is where >> the filters are useful. > > Thanks for the explanation. It motivated me to play with these two > boxes: If I don't want to have the auto-generated entry 'Form1' to be > in the po file I must enter this string in the box "Originals". > Alternatively I can use the identifier of the caption in the box > "identifiers" - it must be entered in the po syntax: "tform1.caption", > or "tform1.button1.caption" for a button named TButton. What was > confusing me is that the ignored entries remain in the master po and > translated po files after these modifications. Only after "Clean up and > Build" they do disappear. This, however, takes a long time because all > required units are recompiled. Wouldn't it be better to have a menu > command "Clean po file" which just rebuilds the rsj and po files? You have for this: 1. 'Project Options' -> 'i18n' -> 'Force PO files update on next compilation' check box at the bottom of the page. 2. 'Project' -> 'Resave forms with enabled i18n' in main Lazarus menu to regenerate all .lrj files in project. -- Best regards, Maxim Ganetsky mailto:gan...@narod.ru -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
Am 26.01.2018 um 12:05 schrieb Werner Pamler via Lazarus: Wouldn't it be better to have a menu command "Clean po file" which just rebuilds the rsj and po files? Ah - there's a checkbox "Force update po files after next compile" for this purpose. But this is not working. It requires a Run > Build instead of Run > Compile. I suggest it is renamed to "Force update po files after next build" -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
26.01.2018 14:24, Werner Pamler via Lazarus пишет: > Am 26.01.2018 um 12:05 schrieb Werner Pamler via Lazarus: >> Wouldn't it be better to have a menu command "Clean po file" which >> just rebuilds the rsj and po files? > > Ah - there's a checkbox "Force update po files after next compile" for > this purpose. But this is not working. It requires a Run > Build instead > of Run > Compile. I suggest it is renamed to "Force update po files > after next build" Done, thanks for the hint. -- Best regards, Maxim Ganetsky mailto:gan...@narod.ru -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Sharing translations between Lazarus and Delphi versions of the same project
Am 26.01.2018 um 16:22 schrieb Maxim Ganetsky via Lazarus: 26.01.2018 14:24, Werner Pamler via Lazarus пишет: Ah - there's a checkbox "Force update po files after next compile" for this purpose. But this is not working. It requires a Run > Build instead of Run > Compile. I suggest it is renamed to "Force update po files after next build" Done, thanks for the hint. Thank you. And I added a note to the i18n options wiki help page: http://wiki.lazarus.freepascal.org/IDE_Window:_Project_Options#i18n There is a problem with the approach of putting these ignores into these listboxes here. Because this list is ignored by codetools. This means: if I rename a unit which has a matching entry in the excluded identifiers list then this entry will not be updated, and the related entries will be left uselessly in the list. Either codetools should have a look at them (in creation of the po file, the renamed units are handled correctly), or the ignored entries should be defined by code, similar to gnugettext's original "TP_GlobalIgnoreClassProperty" procedure. -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus