Recent

Author Topic: Reading Embeded PO Files  (Read 718 times)

CMELIGM

  • New member
  • *
  • Posts: 9
Reading Embeded PO Files
« on: June 13, 2025, 08:35:05 am »
Hello,

i am using PO Files to translate my Application and so far it all works out like expected. i recently embeded my po Files into the Executable using project settings -> resources.

i am currently extracting the files from the executable again when using it:
Code: Pascal  [Select][+][-]
  1. initialization
  2.   ForceDirectories(Application.Location + 'languages');
  3.   ExtractResource('MyApplication.DE', 'languages\MyApplication.de.po', true);
  4.   ExtractResource('MyApplication.EN', 'languages\MyApplication.en.po', true);    
  5.  


and to switch language i use:
Code: Pascal  [Select][+][-]
  1. SetDefaultLang('en', 'languages');
  2.  

This works but i wonder if there is also a way where i do not have to extract the Files and can directly use them ?. so skip the steps "ExtractResource"

i tried this: "https://wiki.lazarus.freepascal.org/Everything_else_about_translations#Compiling_po_files_into_the_executable_and_change_language_while_running"

but i did not work for me (i also did not fully understand what is going on).

Thaddy

  • Hero Member
  • *****
  • Posts: 17396
  • Ceterum censeo Trump esse delendam
Re: Reading Embeded PO Files
« Reply #1 on: June 13, 2025, 10:00:11 am »
The overhead is almost not there or very low: why would you need that?
I think you can also include the PO files as RT_RCDATA resource entries. Then there is no overhead at all.(just a pointer change)
« Last Edit: June 13, 2025, 10:05:33 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Bart

  • Hero Member
  • *****
  • Posts: 5575
    • Bart en Mariska's Webstek
Re: Reading Embeded PO Files
« Reply #2 on: June 13, 2025, 01:34:25 pm »
Maybe this unit of mine can give you some pointers?

Bart

CMELIGM

  • New member
  • *
  • Posts: 9
Re: Reading Embeded PO Files
« Reply #3 on: June 16, 2025, 09:48:14 am »
The overhead is almost not there or very low: why would you need that?
I think you can also include the PO files as RT_RCDATA resource entries. Then there is no overhead at all.(just a pointer change)

it would be great to not have the PO Files lying around in the install Folder.

Maybe this unit of mine can give you some pointers?

Bart

Thank you, this was indeed helpful.

Thaddy

  • Hero Member
  • *****
  • Posts: 17396
  • Ceterum censeo Trump esse delendam
Re: Reading Embeded PO Files
« Reply #4 on: June 16, 2025, 10:54:41 am »
Tnx Bart for the real life example I was too lazy to provide.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018