Anders Melander 1784 Posted July 28, 2020 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. Share this post Link to post
John Kouraklis 94 Posted August 6, 2020 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
Anders Melander 1784 Posted August 6, 2020 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
John Kouraklis 94 Posted August 6, 2020 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
lincesmarques 0 Posted October 8, 2020 How to add another language to translate for? Share this post Link to post
Anders Melander 1784 Posted October 8, 2020 20 minutes ago, lincesmarques said: How to add another language to translate for? Select the language in the Target combobox. 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: 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
Antony Danby 1 Posted November 25, 2020 Anders, I've started playing with this and already it's way better than ITE I think... Just struggling with one thing: How can you code it in delphi so that it switches from one language to another whilst in the application ? Share this post Link to post
Anders Melander 1784 Posted November 25, 2020 Thanks. Please read the last part of the answer for info on controlling the active language: ...But be aware that once a form has been created (and thus the DFM loaded from the resource module) you will need to either recreate the form or reload it from the DFM resource (not recommended) in order for it to use the new language. Share this post Link to post
Antony Danby 1 Posted November 25, 2020 Anders, I need it to be switchable in the code I used to have a bit of code for doing this on ITE: procedure TForm3.Button1Click(Sender: TObject); const GERMAN = (SUBLANG_GERMAN shl 10) or LANG_GERMAN; begin if LoadNewResourceModule(GERMAN) <> 0 then ReinitializeForms; end; However, I had forgotten what needs to be in the uses for this. Share this post Link to post
Anders Melander 1784 Posted November 25, 2020 3 minutes ago, Antony Danby said: I used to have a bit of code for doing this on ITE: procedure TForm3.Button1Click(Sender: TObject); const GERMAN = (SUBLANG_GERMAN shl 10) or LANG_GERMAN; begin if LoadNewResourceModule(GERMAN) <> 0 then ReinitializeForms; end; However, I had forgotten what needs to be in the uses for this. There's no difference between ITE and BTM in that regard. They use the exact same RTL mechanism. Ie. the BTM and ITE resource modules are identical. It's only the localization editor/manager/compiler that's different. I believe LoadNewResourceModule used to be in the RichEdit example (no longer included with Delphi but you can find it on the net). Instead you can use LoadResourceModule, in the system unit, or my version of LoadNewResourceModule, in the amLocale unit of the BTM source. Share this post Link to post
Antony Danby 1 Posted November 30, 2020 I am really impressed with BTM. It really does work and much better than ITM/ITE, but I have a problem, the same one I have with ITM/ITE: As you can maybe see from the screen shot this was a little application I did in English and got BTM to translate to German, Which it's done, but the Shortcut's are not translated. I have checked and tried over and over the translated side is "Strg+" and it is all in there. Do you know why this doesn't work ? Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 8 minutes ago, Antony Danby said: the Shortcut's are not translated. BTM only translates strings and shortcuts are stored in the DFM as integer values. It's really not good practice to translate the shortcuts anyway. For example the user would expect Copy to be Ctrl+C regardless of the language. Instead you can translate the accelerator keys since these are part of the menu text. E.g. &Copy -> Copy = &Kopieren -> Kopieren If you really want to translate the shortcuts, and have BTM handle translation of them, then I'm afraid you'll have to store them in text format as resourcestrings and then use TextToShortCut to convert the text to a shortcut at run time: resourcestring sShortcutCopy = 'Ctrl+C'; begin MenuCopy.ShortCut := TextToShortCut(sShortcutCopy); end; Share this post Link to post
toms 29 Posted November 30, 2020 This is what I came up about 12 years ago: https://www.delphipraxis.net/120614-bezeichnungen-von-shortcuts-aendern-aber-wie-2.html Share this post Link to post
Antony Danby 1 Posted November 30, 2020 That didn't work, sorry: The SwitchSoftwareLanguage call works and has been working for some time. So I tried to add in this 'Ctrl+C' and a routine called FixMenuShortcuts; Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 11 minutes ago, Antony Danby said: That didn't work, sorry: The SwitchSoftwareLanguage call works and has been working for some time. So I tried to add in this 'Ctrl+C' and a routine called FixMenuShortcuts; You need to swap the order of FixMenuShortcuts and SwitchSoftwareLanguage... Share this post Link to post
Antony Danby 1 Posted November 30, 2020 I already tried that, when I do it the Ctrl + C shortcut disappears ?? Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 14 minutes ago, toms said: This is what I came up about 12 years ago: https://www.delphipraxis.net/120614-bezeichnungen-von-shortcuts-aendern-aber-wie-2.html I'm not sure what that is supposed to do (I don't read German that good). If the purpose is to translate the texts returned by TextToShortcut then it is unnecessary since the texts are already resourcestrings. Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 2 minutes ago, Antony Danby said: I already tried that, when I do it the Ctrl + C shortcut disappears ?? You need to translate the sShortcutCopy text in BTM to German and the translated text should use the German key names. I don't know what those are. The key shortcut names are defined in Vcl.Consts: SmkcBkSp = 'BkSp'; SmkcTab = 'Tab'; SmkcEsc = 'Esc'; SmkcEnter = 'Enter'; SmkcSpace = 'Space'; SmkcPgUp = 'PgUp'; SmkcPgDn = 'PgDn'; SmkcEnd = 'End'; SmkcHome = 'Home'; SmkcLeft = 'Left'; SmkcUp = 'Up'; SmkcRight = 'Right'; SmkcDown = 'Down'; SmkcIns = 'Ins'; SmkcDel = 'Del'; SmkcShift = 'Shift+'; SmkcCtrl = 'Ctrl+'; SmkcAlt = 'Alt+'; I.e. find out what SmkcCtrl is translated to in German. Share this post Link to post
Uwe Raabe 2057 Posted November 30, 2020 4 minutes ago, Anders Melander said: find out what SmkcCtrl is translated to in German. It is "Strg+" One can get these translations when Delphi is installed with the German language pack (similar for French and Japanese). Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 2 minutes ago, Uwe Raabe said: It is "Strg+" One can get these translations when Delphi is installed with the German language pack (similar for French and Japanese). Thanks. That must be the abbreviation of "Steuerung" I guess. Makes sense. The translated RTL resource strings are also available in the ITE translation memory and that is installed regardless of Delphi's language. Share this post Link to post
Antony Danby 1 Posted November 30, 2020 (edited) I already did the SmkcCtrl conversion a long time ago, which is why I was baffled when none of it was working: Would it be easier for me to zip up my test project and send it to you ? Edited November 30, 2020 by Antony Danby Share this post Link to post
Anders Melander 1784 Posted November 30, 2020 2 minutes ago, Antony Danby said: I already did the SmkcCtrl conversion a long time ago, which is why I was baffled when none of it was working: I think you'll have to debug a bit then. Set a breakpoint on the call to TextToShortcut and trace into it to see what's going wrong. Share this post Link to post
Antony Danby 1 Posted November 30, 2020 I'll have to do that later today ! Anything I find if it's significant then I'll share it with you 1 Share this post Link to post
GillesCat 0 Posted January 29, 2021 Hi, I use Delphi5 on Windows10 and Delphi5 does not use .DRC files. Can I use your program? If so, can you help me do this? Thank you Share this post Link to post
Anders Melander 1784 Posted January 29, 2021 7 hours ago, GillesCat said: Delphi5 does not use .DRC files. Can I use your program? I've just read the Delphi 5 help and as far as I can see Delphi 5 does produce DRC files. What makes you say it doesn't? Share this post Link to post