Jump to content
Anders Melander

ANN: Better Translation Manager released

Recommended Posts

Hi,

 

We have a challenge in distributing our exe files and language files to our customers and keeping the respective file versions  (exe and language files) in sync, due to files in use, locked etc.

 

Does anyone know a solution to, for example, include the language files into the .exe file and then extract the language files when the starting the exe file ?

 

Best regards

Roy Nielsen 

Share this post


Link to post
17 minutes ago, roynielsen2000@gmail.com said:

We have a challenge in distributing our exe files and language files to our customers and keeping the respective file versions  (exe and language files) in sync, due to files in use, locked etc.

It's been a while but I thought all your customers were using remote desktop against servers hosted and managed centrally by you.

 

Regardless, I guess a self-extracting exe could be used. For example a simple zip self-extractor or even an Inno Setup installer with no GUI. However if your problem is file locking (presumably because the files are in use), I can't see that you won't still have the same problem; If the files are locked the extraction will not be able to replace them.

 

I think it would be better to concentrate on solving the deployment problem instead of working around it.

Share this post


Link to post
1 hour ago, roynielsen2000@gmail.com said:

We have a challenge in distributing our exe files and language files to our customers and keeping the respective file versions  (exe and language files) in sync, due to files in use, locked etc.

Why not just include language files inside exe?

Share this post


Link to post
2 hours ago, roynielsen2000@gmail.com said:

Does anyone know a solution to, for example, include the language files into the .exe file and then extract the language files when the starting the exe file ?

If you happen to use dxgettext, there is the assemble tool for that. But given the topic you're posting under, you probably don't use it.

Edited by dummzeuch

Share this post


Link to post
2 minutes ago, Fr0sT.Brutal said:

As resources

Potential chicken-egg problem:

  1. The translation is based on the exe file.
  2. The language module is based on the translation + exe.
  3. In order to get the language module linked into the resources of the exe, the exe must be compiled with it.

Of course this isn't impossible in any way, and you can even make a tool that adds the file to the exe's existing resources, but then there's the next problem: The resource modules must be extracted from the exe before the exe loads the resource module, which by default happens in the initialization section of system or sysutils, I forget which.

 

All in all, I'd say it's probably easier and more robust to solve the original problem instead of all these workarounds.

Share this post


Link to post
3 minutes ago, Anders Melander said:

The translation is based on the exe file.

Ah, that scheme. I was thinking about text files.

Anyway resources could be added at post-build stage and application could extract them at 1st run and then relaunch. However, I agree this is the task for installer

Share this post


Link to post

Our old Sisulizer tool added the language resource files to our exe files after the build and we extract the resource files and reloads a users chosen language at runtime (we also switch the language "on-the-fly" by re-initializing the forms and call System.SysUtils.ResStringCleanupCache

I have been experimenting with adding the language files as a resource, but as Anders writes, it's the chicken-egg problem with that solution

 

How can I add the resources to a .exe files after it is build ? Does someone know how this is done ?

Share this post


Link to post
47 minutes ago, roynielsen2000@gmail.com said:

How can I add the resources to a .exe files after it is build ? Does someone know how this is done ?

brc32 (part of Delphi) should be able to do that. There are probably quite a few other tools.

On the other hand: Why do you need to do that after the exe has finished building? If your files already exist at that point, why not simply add them using the {$R filename.res} directive in the source code?

Share this post


Link to post
13 minutes ago, dummzeuch said:

Why do you need to do that after the exe has finished building?

That was my question as well but from what Anders said I understood that language resources are built on the basis of compiled exe. Anyway the build script (topic starter is using build scripts isn't he?) could run two passes so the issue is solved.

Share this post


Link to post

Okay then, assuming your exe isn't signed you can try this:

 

At build time (after the exe and language modules have been built):

  1. Zip your language modules into a single file.
  2. Append the zip to the end of the exe file.
  3. Append a int64 containing the original size of the zip to the end of the exe file.

You will need to make a tool that does the above. It shouldn't be too hard.

 

At run time:

  1. Open a TFileStream on the exe and read the int64 from the end of the exe.
    This gives you the position of the zip inside the exe.
  2. Seek the stream to the position of the zip.
  3. Open a TZipFile on the stream and extract the files to disk.

If your exe is signed you will need to use a different approach. See https://blog.barthe.ph/2009/02/22/change-signed-executable/

 

See also: https://stackoverflow.com/questions/5795446/appending-data-to-an-exe

 

Share this post


Link to post

Adding to binary is an x-platform way but if targeting only Windows, isn't it better to use UpdateResource ?

And what's the sense of signing a file and then struggling with the signature instead of signing the prepared binary with all modules included?

Share this post


Link to post
3 minutes ago, Fr0sT.Brutal said:

Adding to binary is an x-platform way but if targeting only Windows, isn't it better to use UpdateResource ?

I can't see why it's "better", it's certainly more complicated, but yes that's also an alternative. AFAIR resources are mapped into the process virtual address space so that will have to be taken into consideration.

 

4 minutes ago, Fr0sT.Brutal said:

And what's the sense of signing a file and then struggling with the signature instead of signing the prepared binary with all modules included?

I'm not sure you can sign an exe that has had data appended and even if you can you risk that the signature data is added after the data you appended thus breaking the extraction scheme.

Share this post


Link to post
12 minutes ago, Anders Melander said:

I'm not sure you can sign an exe that has had data appended and even if you can you risk that the signature data is added after the data you appended thus breaking the extraction scheme.

Fair point

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×