Delphi Exception message text in wrong language
Asked Answered
K

1

6

I have an application where I catch exceptions and show the message text to the user as part of the error message. Allthough RAD Studio (10.1) is set to English and the Locale ID is set to 409 English in the Version Info options for all Targets the error message is output in German. This happens both on a German Windows 10 and other Windows machines with other languages, even a Japanese customer got this.

The exception is a system exception like failed to open file, file not found, but it seems it happens on all kind of exceptions that I do not raise with my own message text.

The project has been migrated from Delphi 2007 recently and I had to do some manual clean up in the project files regarding the version numbers. But checking the Locale in the project file reveals no surprise: 1033 -> $0409 - English.

Where could be the reason for the German messages?

Kinesics answered 13/11, 2017 at 12:34 Comment(12)
delphi-10.1-berlin. Nah, that can't be it. ;-) But maybe you got different build configurations (like debug/release 32bit/64bit), and have set the correct language for some but not all.Ballistic
I take it this application was built on a German machine?Xylidine
Definitly not: All configurations have the same value for the locale ID.Kinesics
Can you show us your code for catching and showing the error texts?Xylidine
@Dsm: Yes, The machine is a German Win 10.Kinesics
@Dsm: The code is trivial. I tried the following for testing: try # StringList.LoadFromFile (NotExistingFilename) # except # on e : exception do # showmessage ('Exception Message: ' + e.message); # endKinesics
@kobik: GetThreadLocale returns 407, which is the code for German. Not really surprising, but where is this value set? I searched for SetThreadLocale but found nothing. Any other hints what might set the locale?Kinesics
@Veit, I removed that comment about GetThreadLocale because I realized the exception string is taken from the resource-strings. so this string is already compiled into your application. So your application is already pre- configured to use locale 407.Hectocotylus
What I once did to get rid of certain german exception strings was to rename the "de" path in lib directory to "_de" . The system used these on a build "without runtime packages" on my system... Pherhaps that helps you too... Note that I didn't find the proper switch or setting to do it otherwise.Ramses
I just discovered in the Add Language dialoge (in the main menu -> project -> language -> add...), that the applications base language is obviously defined as $0407. But I can't change it there. Where can I change that value?Kinesics
Third line executed in system.pas: SetThreadLocale(LOCALE_USER_DEFAULT); So it seems that German resources are linked to the application, even though you tell it otherwise. Did you verify with a resource editor?Madoc
@whosrdaddy: Resource Hacker shows 1033 in almost all categories.(Cursor, Icon, Cursor Group, Icon Group, Version Info, and Manifest). Only in String Table the entries are all German and the locale ID is 0. The entries have resource IDs from 4075 to 4096. Each Entry starts with "LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL"Kinesics
K
2

After searching for the solution every time I could spend some minutes in the last days, I solved it!

When using the BDSSetLanguage.exe tool in the bin folder of Rad Studio you not only can change the IDE's language but also the library's language. IDE was set to English and Library was set to German. Setting the library's language to English solved the problem.

Thanks to @mrabat sending me in the right direction. But since his tip was only a hack rather than a permanent solution, I think I can't give any official credits here.

Kinesics answered 15/11, 2017 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.