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

@Anders Melander Was does this mean? 🙂

 

image.png.171991b3e0c10f21692447e3f090c19c.png

 

Edit: A nice addition would be to have an option to show only changed entries (whether added, obsoleted or marked as unused). That would probably tell me if I should be worried.

 

Edit-edit: Git showed it. An item has been un-unused:

image.thumb.png.6092c1cad5515cf239a0314601c11527.png

Edited by aehimself

Share this post


Link to post
2 hours ago, aehimself said:

Edit: A nice addition would be to have an option to show only changed entries (whether added, obsoleted or marked as unused). That would probably tell me if I should be worried.

Good idea. Optimally I'd like to have a dialog that shows exactly (in a grid that can be sorted grouped and searched) what changed.

There are several cases where it would be much better to use a custom form instead of a standard message dialog, but it's just so much faster (in terms of implementing it) to just display a message dialog.

 

2 hours ago, aehimself said:

Edit-edit: Git showed it. An item has been un-unused:

Yes 🙂 Not very intuitive. I'll see if I can differentiate between the three cases: Added, Unused and Re-added.

  • Like 1

Share this post


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

Does the commandline tool update the project when generating language files ?

No.

 

23 minutes ago, roynielsen2000@gmail.com said:

If not, is it possible to include that functionality ?

I'm guessing you want it to update the project with any changes made to the EXE, right?

But why? What problem are you trying to solve?

Share this post


Link to post
2 hours ago, Anders Melander said:

But why? What problem are you trying to solve?

I have only one valid explanation, which is I usually forget to sync and build a new language file and therefore the .xlat goes in in a separate commit.

However, for the actual translation you need the GUI anyway and if you update the .xlat beforehand, you'll have no idea if there was a change or not (especially if we'll have the option to see changed entries only).

 

So after all it would solve my issue of the file going in in a separate commit, but it's still not translated and built, so it would add no actual value.

Share this post


Link to post
On 1/20/2023 at 8:54 AM, Anders Melander said:

No.

 

I'm guessing you want it to update the project with any changes made to the EXE, right?

But why? What problem are you trying to solve?

Hi,

 

I would like to solve the problem when a developer do not update the xlat file from a newly built .exe file, we had an example yesterday actually.

Sometimes when a developer forgets to sync, the translations on various components can be wrong, one example from yesterday was headers on a database grid with wrong titles and the forms caption bar title text was also wrong. After an update og the xlat file and a new build, problem was solved, but some customers already had the wrong version.

 

Share this post


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

I would like to solve the problem when a developer do not update the xlat file from a newly built .exe file, we had an example yesterday actually.

Sometimes when a developer forgets to sync, the translations on various components can be wrong, one example from yesterday was headers on a database grid with wrong titles and the forms caption bar title text was also wrong. After an update og the xlat file and a new build, problem was solved, but some customers already had the wrong version.

This is really a problem in your workflow, not a deficiency of the tool.

 

In a company of your size, with an off-the-shelf product, you really should be using a build server to produce the deliverables and not relying on individual developers to produce the files.

The language modules will never get out-of-sync or contain the wrong texts if they are produced against the most recent exe file. It doesn't matter if the xlat file (the translation project) was updated or not. Translations might be missing (i.e the source texts are not translated), but they will never be mismatched.

 

Mismatched texts mean that you are using a language module that was produced for another version of the exe. If your exe contains a version resource, and you remember to bump the version with each new build, then the resource module loader will validate the language module version against the exe version on load.

 

I would recommend you use a workflow similar to this:

988676278_BTMworkflow.thumb.png.31572a44e876b486cf0ddea9b7361634.png

 

As I said, I can add a switch to have the command line tool save the project file but I can't see that it would have made a difference in your case.

Share this post


Link to post

Is possible to keep translations in sub folder?

.\Test\Test.exe
.\Test\lang\Test.fr-FR
.\Test\lang\Test.de-DE

 

 

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

×