Jump to content
Anders Melander

ANN: Better Translation Manager released

Recommended Posts

1 hour ago, Jan Doggen said:

function IsAnsi(c: char): boolean; Inline;
begin
  // Result := (c <= #$FF); [JD]
  Result := (Ord(c) <= $FF);
end;

I don't understand why you would get a compiler warning on that.

I'm not getting it with Delphi 10.3.3 and since you are compiling from the source on bitbucket we should be using the exact same compiler options.

 

1 hour ago, Jan Doggen said:

Invalid source language ID: 2000

This is really strange. You are getting an error when the project default source language is set. The origin of the default value is the GetUserDefaultLCID Win32 API function... but $2000 isn't a valid LCID value.

My guess is that you are using a custom locale (see: Locale Names without LCIDs). I had hoped I wouldn't have to deal with those but I guess I weren't that lucky.

You can probably work around the problem by modifying the default locale settings in the registry:

HKEY_CURRENT_USER\Software\Melander\TranslationManager\System
DefaultSourceLanguage=1033
DefaultTargetLanguage=1033

The above values sets them to "English (United States)".

I will have to see if I can reproduce the problem here and then figure out how to deal with it. Stay tuned...

 

1 hour ago, Jan Doggen said:

Can a program be written in such a way that it picks a *specified* language file. Preferably at runtime (sometime during program startup). Or is BTM just not the tool for that?

There are several ways you can control what language to use at run time.

Start by reading the Delphi help topic "Deploying Localized Applications". This explains how you can override the default language choice using the registry.

BTM itself can be used as an example of how to load a specific resource module based on a user choice. Look in amTranslationManager.dpr in the function named LoadResourceModule and in amLocale.pas in the function named LoadNewResourceModule.

There used to be a Delphi example project (RichEdit or something like it) that demonstrated how to localize an application and how to switch resource modules at run time but I don't think it's been included for a while.

image.thumb.png.8abb90aac7694d2b3137293325a6fa27.png

Share this post


Link to post

HI,

 

Thanks a great app. Thanks for the contribution.

 

I've got two questions:

 

1. Does the translation work in FMX apps? 

 

2. Is there a way to load a resource file at run-time without the need to restart the translated app?

 

Thanks

Share this post


Link to post
6 hours ago, John Kouraklis said:

1. Does the translation work in FMX apps? 

On Windows: Yes. Everywhere else: No.

On Windows it works the exact same way as with VCL; Forms are stored in the EXE resources in DFM format and resourcestrings are stored as string resources.

 

AFAIK for cross platform FMX you were supposed to use the TLang component for localization and invent your own system for managing and applying translations, but that system has been deprecated as well.

 

6 hours ago, John Kouraklis said:

2. Is there a way to load a resource file at run-time without the need to restart the translated app?

Yes, you can load resource modules dynamically (they are just DLLs) but forms that have already been instantiated will not be affected by this. This means that if you create a form and switch to another language, then the form will stay in the original language.

The post just above yours points to an example:

On 7/28/2020 at 9:34 PM, Anders Melander said:

Look in amTranslationManager.dpr in the function named LoadResourceModule and in amLocale.pas in the function named LoadNewResourceModule.

 

Share this post


Link to post
2 hours ago, Anders Melander said:

On Windows: Yes. Everywhere else: No.

On Windows it works the exact same way as with VCL; Forms are stored in the EXE resources in DFM format and resourcestrings are stored as string resources.

Yes, I was sure that other platforms wouldn't be easy to work with. 

 

Thanks for the tips.

Share this post


Link to post
20 minutes ago, lincesmarques said:

How to add another language to translate for?

Select the language in the Target combobox.

image.png.a52d0da2b90e5732fd6e26b8140414f3.png

If you click the small button below the combobox you'll get a dialog where you can enable an options that filters the list of available languages:

image.thumb.png.4276517da39f0314d377ffd32965c3a7.png

 

Note that, even though your project can contain translations for multiple languages, you can only edit one language at a time.

 

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

×