Lazarus

Miscellaneous => Translations => Topic started by: ying18 on January 24, 2021, 05:39:34 pm

Title: Embed .po files into exe, unclear on the next step
Post by: ying18 on January 24, 2021, 05:39:34 pm
I have several language translations (.po files) for a program of mine stored in a languages subfolder and starting the program using switches on the commandline successfully changes the language of the program.
Now I want to embed the translations in the program so that I can distribute it as a standalone binary but I'm finding conflicting tutorials online.
Some advise converting the .po files to a resource, some say to compile to a .mo file first and then add that as a resource.
Also the advice on how to add a resource differs from using lazres on the command line to just going to Project Options > Add Resource

Can anyone recommend an up-to-date tutorial online, or can offer tips here, that will allow me to embed multiple translations into a program?
Thanks
Title: Re: Embed .po files into exe, unclear on the next step
Post by: marcov on January 24, 2021, 06:26:34 pm
Note that when you search on this, you might find results for Delphi and/or dxgettext library, which is afaik different then what Lazarus uses.

I use Delphi+dxgettext at work, and there indeed with recent versions (as in for Delphi 2009+ versions) you can link in .mo's into resources. 

I never done much internalisation in Lazrus
Title: Re: Embed .po files into exe, unclear on the next step
Post by: Bart on January 24, 2021, 08:25:00 pm
You can have a look at a unit of mine (http://svn.code.sf.net/p/flyingsheep/code/trunk/MijnLib/nlautotranslation.pp) that embeds the LCL translation in the executable.
It uses old style .lrs Lazarus resources.
You need lazres to create the .lrs file.
It is based upon a wiki article about traslations, but this article has been rewritten, and that code example has been removed (the whole subject of embedding it in the executable has been removed).

Bart
Title: Re: Embed .po files into exe, unclear on the next step
Post by: lainz on January 24, 2021, 10:29:59 pm
You can have a look at a unit of mine (http://svn.code.sf.net/p/flyingsheep/code/trunk/MijnLib/nlautotranslation.pp) that embeds the LCL translation in the executable.
It uses old style .lrs Lazarus resources.
You need lazres to create the .lrs file.
It is based upon a wiki article about traslations, but this article has been rewritten, and that code example has been removed (the whole subject of embedding it in the executable has been removed).

Bart

I think it's here
https://wiki.freepascal.org/Everything_else_about_translations#Compiling_po_files_into_the_executable_and_change_language_while_running

I've done the article changes you mention a lot of years ago, but I've not removed the stuff, just moved it =)
Title: Re: Embed .po files into exe, unclear on the next step
Post by: Bart on January 25, 2021, 11:04:54 pm
I think it's here
https://wiki.freepascal.org/Everything_else_about_translations#Compiling_po_files_into_the_executable_and_change_language_while_running

I've done the article changes you mention a lot of years ago, but I've not removed the stuff, just moved it =)

Thank you, I searched for it a while ago but didn't find it.
Now for the fun part: using old style Lazarus resources is, well, old style.
Can we rewrite this so that it uses the new fpc resource style?

Bart
Title: Re: Embed .po files into exe, unclear on the next step
Post by: Handoko on January 27, 2021, 04:08:36 pm
Please attention on the hidden link in the first post:
Title: Re: Embed .po files into exe, unclear on the next step
Post by: Martin_fr on January 27, 2021, 04:14:45 pm
OT is spam. Link removed. Account deleted.
Original post https://forum.lazarus.freepascal.org/index.php/topic,35350.0.html

I keep this thread, due to the replies it has gotten.
TinyPortal © 2005-2018