0

I have a Java application on macOS that uses SWT. Sometimes this application needs to ask for a filename. Now, while SWT has a file dialog, this is sort of broken in recent versions.

So I made my own file dialog that uses JNA to create an NSSavePanel via the Objective C runtime. This way I can get rid of the "Tags" field and handle file extensions correctly. Works like a charm, except: my macOS is in German, but the NSSavePanel is in English (as is the one from SWT). How do I get the dialog to use the system's language?

The application also uses a custom Java launcher. I haven't tried if tweaking the available languages in the launcher's build file would help, because for various reasons I'd rather avoid rebuilding that. Is there a way to achieve this with Cocoa (or Core Foundation) APIs only?

Edit: we've checked on a system with High Sierra and the dialog is in German there

user2543253
  • 2,143
  • 19
  • 20
  • Note that macOS SWT already has a `NSSavePanel` class in `org.eclipse.swt.internal.cocoa` – greg-449 May 14 '20 at 10:48
  • @greg Yes. But it's in English, too. And as I said, it is broken in recent versions of SWT and Cocoa. Catalina doesn't let you change the file's name in the callback anymore. That means SWT cannot append its file extension. You have to set `allowedFileTypes` and SWT doesn't do that. (Also the SWT file dialog always shows the Tags field, and we don't want that) – user2543253 May 14 '20 at 11:02
  • @greg Sorry, you meant the *internal* `NSSavePanel`. This unusable because it doesn't have all the needed messages and you can't get callbacks from it, because Display explicitly checks for a `FileDialog` instance in its event handler. – user2543253 May 14 '20 at 11:08

0 Answers0