Recent

Author Topic: Embed .po files into exe, unclear on the next step  (Read 8586 times)

ying18

  • Guest
Embed .po files into exe, unclear on the next step
« 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
« Last Edit: January 27, 2021, 04:13:11 pm by Martin_fr »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Embed .po files into exe, unclear on the next step
« Reply #1 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

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Embed .po files into exe, unclear on the next step
« Reply #2 on: January 24, 2021, 08:25:00 pm »
You can have a look at a unit of mine 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

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Embed .po files into exe, unclear on the next step
« Reply #3 on: January 24, 2021, 10:29:59 pm »
You can have a look at a unit of mine 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 =)

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Embed .po files into exe, unclear on the next step
« Reply #4 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

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Embed .po files into exe, unclear on the next step
« Reply #5 on: January 27, 2021, 04:08:36 pm »
Please attention on the hidden link in the first post:

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Embed .po files into exe, unclear on the next step
« Reply #6 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