Localization of Open/Save dialogs for non-English languages lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Igor · 2021-01-04 13:38 Users of my app from non-English countries complaint that OpenDialog and SaveDialog are always shown on English language (including overwrite file prompts). The same problem with Lazarus IDE. Even if I set French or German language for user interface, all Open/Save dialogs stay on English (despite the fact that macOS also use French or German interface). How to modify my app bundle to use current UI language from macOS? I read that I should add localization options in Xcode project that automatically modifies the APP bundle, but we use Lazarus. So we should do it manually. ---------------------------------------------------------------------- trev · 2021-01-05 04:39 Apple's Xcode localisation article is pretty easy to understand, but I do not think this is what you really want because I'm reasonably certain it is not going to work with a Lazarus-created application. Have you looked at the Wiki article Step-by-step instructions for creating multi-language applications ? Disclaimer: I've never localised anything other than an Apple help book as a demo. ---------------------------------------------------------------------- dbannon · 2021-01-05 06:04 I don't think its a problem for Igor to solve by reading wiki. When a translator translates to another language, he/she gets a list of the text the programmer has used in the application.  But there is a second list, one made up of all the text from LCL, such things as open dialogs.  That list ends up in a file called lclstrconsts."$CCODE".mo That LCL translation is done by the LCL developers (bless them) and it looks to me as if they have missed the file dialog boxes. I just switched my app to Spanish and sure enough, a save dialog still comes up in English. Davo ---------------------------------------------------------------------- Igor · 2021-01-05 07:53 My app is translated to other languages, using internal code and language strings based on .ini files. The problem is only with file Open/Save dialogs. Regrettably Wiki article doesn't describe this situation for macOS. I've read Apple's documentation for this subject. Yes, it's possible to manually translate some text captions in Open/Save dialogs. Not all. You will not able to translate names of user's folders (Documents, Music, Desktop) in the list of folders on the left side. We need to "tell" macOS that Open/Save dialogs should be translated automatically by macOS on OS side. Not a manual translation by our app. I have no idea how to do it. ---------------------------------------------------------------------- PascalDragon · 2021-01-05 07:55 Quote from: dbannon on January 05, 2021, 07:04:13 amI just switched my app to Spanish and sure enough, a save dialog still comes up in English. The file dialogs are done by the OS, not the LCL. Thus one needs to correctly tell the OS to translate the dialog (e.g. on Windows the OS language will be used). And that's the question that Igor Kokarev has. ---------------------------------------------------------------------- Igor · 2021-01-05 08:06 Quote from: PascalDragon on January 05, 2021, 08:55:16 amThe file dialogs are done by the OS, not the LCL. Thus one needs to correctly tell the OS to translate the dialog (e.g. on Windows the OS language will be used). And that's the question that Igor Kokarev has. Yes. And it would be great if Lazarus IDE also could use OS language in Open/Save dialogs. Or language set for IDE in Lazarus's Preferences. ---------------------------------------------------------------------- trev · 2021-01-05 08:55 The solution is very simple as it turns out   Just add this to your application's Info.plist file: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         CFBundleLocalizations                        en                fr                ...etc...        Your application will then  present the system dialogs in the user's preferred language. See attached pic. ---------------------------------------------------------------------- Igor · 2021-01-05 13:12 trev, Thanks for your advice. It's strange, but it doesn't work for me. I switched OS language to French and restarted macOS. I created a new project and added these keys to Info.plist (English and French). However Open/Save dialog stay on English (OS language is French, and Chrome shows Open dialog on French). I attach my test project (without executable file). macOS 11.1 Big Sur, Lazarus 2.1.0 / FPC 3.2.1 fixes. P.S. I checked other apps. For example, TextEdit shows localized Open/Save dialogs but it's Info.plist doesn't include any CFBundleLocalizations records. ---------------------------------------------------------------------- trev · 2021-01-05 21:36 Your test application worked for me - when I changed my language to French, restarted, your open dialog was in French ... I tested it under Mojave, Catalina and Big Sur (ARM64). Weird! I can't think why it does not work for you... did you try copying the executable into the MacOS folder and deleting the symbolic link? Have you tried it on other machines? ---------------------------------------------------------------------- Igor · 2021-01-05 23:05 trev, Thanks! You gave me an idea. Localization in NSOpenPanel / NSSavePanel does NOT work when an app uses a symbolic link to executable created by Lazarus. I didn't think about this reason. Seems to be a bug in macOS? So I removed a symbolic link and copied real executable to /MacOS folder and now localization works fine! Also I found two alternative ways to activate localization: A. Add CFBundleLocalizations records as you wrote above. B. Or create an empty folder for each language in /Contents/Resources For example for French fr.lproj in /Resources Probably it would be an useful information for Lazarus Wiki. ---------------------------------------------------------------------- trev · 2021-01-06 02:35 Great! Yes - I've already added the .plist info to the localisation article in the Wiki. I'll also add your find. Thanks! ---------------------------------------------------------------------- Igor · 2021-01-06 07:31 trev, Thanks again!