Re: [Lazarus] .mo files not working in multi language
Hi, On 23.07.2021 00:50, Maxim Ganetsky via lazarus wrote: Yes, this should work the same way for MO files. In this case LCLTranslator unit will not help, functions from GetText should be called instead. Thanks for your effort. Can you give an example here how to substitute LCLTranslator by GetText? Thx Dietmar OpenPGP_0x4A7DA0A7766EC11F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] .mo files not working in multi language
23.07.2021 1:08, Bart via lazarus пишет: On Thu, Jul 22, 2021 at 11:02 PM Maxim Ganetsky via lazarus wrote: Put them to RES or LRS file, link this file to your program, then extract them at runtime to some directory and load it from there. Can't you use them from the resource like you can with po-files? From one of my units that does thi using old style .lrs resource: Yes, this should work the same way for MO files. In this case LCLTranslator unit will not help, functions from GetText should be called instead. -- 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] .mo files not working in multi language
On Thu, Jul 22, 2021 at 11:02 PM Maxim Ganetsky via lazarus wrote: > Put them to RES or LRS file, link this file to your program, then > extract them at runtime to some directory and load it from there. Can't you use them from the resource like you can with po-files? From one of my units that does thi using old style .lrs resource: === type TTransalateFromLazarusResourceResult = (trSuccess, trResourceNotFound, trTranslationError); function TryTranslateFromLazarusResource: TTransalateFromLazarusResourceResult; var LRes: TLResource; PO: TPOFile; SS: TStringStream; B: Boolean; begin Result := trResourceNotFound; LRes := LazarusResources.Find('lclstrconsts.nl','PO'); if LRes <> nil then begin SS := nil; PO := nil; try SS := TStringStream.Create(LRes.Value); //don't use TPoFile.Create(SS,True): it will crash on TranslateUnitResourceStrings if you do PO := TPoFile.Create(SS, False); try B := TranslateUnitResourceStrings('lclstrconsts',PO); if B then Result := trSuccess else Result := trTranslationError; except Result := trTranslationError; DebugLn('Exception while translating LclStrConsts unit form internal resources.'); end; finally if Assigned(SS) then SS.Free; if Assigned(PO) then PO.Free; end; end; end; === -- Bart -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] .mo files not working in multi language
22.07.2021 15:41, Dietmar Braun via lazarus пишет: Hi, On 20.07.2021 23:36, Maxim Ganetsky via lazarus wrote: Make sure you are using at least Lazarus 2.2 RC1. Make sure you do not have PO and POT files in this subdirectory. one further question: Is it possible to add the .mo files as resources so that they are being hold in the exe file? How could I achieve this? Put them to RES or LRS file, link this file to your program, then extract them at runtime to some directory and load it from there. -- 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] .mo files not working in multi language
Hi, On 20.07.2021 23:36, Maxim Ganetsky via lazarus wrote: Make sure you are using at least Lazarus 2.2 RC1. Make sure you do not have PO and POT files in this subdirectory. one further question: Is it possible to add the .mo files as resources so that they are being hold in the exe file? How could I achieve this? Best regards Dietmar OpenPGP_0x4A7DA0A7766EC11F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] .mo files not working in multi language
On 20.07.2021 23:36, Maxim Ganetsky via lazarus wrote: Make sure you are using at least Lazarus 2.2 RC1. Make sure you do not have PO and POT files in this subdirectory. Works like a charm, thank you! Regards Dietmar OpenPGP_0x4A7DA0A7766EC11F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] .mo files not working in multi language
21.07.2021 0:03, Dietmar Braun via lazarus пишет: Hi! sorry if I'm wrong here, but I posed my question in the Lazarus forum and was redirected here, so I am asking here again... After some years of pausing Lazarus development, I just started again with a small project and the problems I had years ago with MultiLanguage - these days, I managed to create a working multilanguage application, but when I try to distribute it, I run into problems. My directory structure looks like this: project (main folder): project1.exe !--languages (sub folder): project1.de.mo, project1.en.mo Make sure you are using at least Lazarus 2.2 RC1. Make sure you do not have PO and POT files in this subdirectory. With this setting, switching from the default (German) to English (en) does not work. It seems the .mo files are just being ignored. When I add the .PO files to the subfolder, it works. Can you advise? I just don't want to have to distribute the plain text .po files... Thx! Dietmar -- Best regards, Maxim Ganetsky mailto:gan...@narod.ru -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] .mo files not working in multi language
Hi! sorry if I'm wrong here, but I posed my question in the Lazarus forum and was redirected here, so I am asking here again... After some years of pausing Lazarus development, I just started again with a small project and the problems I had years ago with MultiLanguage - these days, I managed to create a working multilanguage application, but when I try to distribute it, I run into problems. My directory structure looks like this: project (main folder): project1.exe !--languages (sub folder): project1.de.mo, project1.en.mo With this setting, switching from the default (German) to English (en) does not work. It seems the .mo files are just being ignored. When I add the .PO files to the subfolder, it works. Can you advise? I just don't want to have to distribute the plain text .po files... Thx! Dietmar OpenPGP_0x4A7DA0A7766EC11F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus