I use the Path Control call in my applet to show a popup which users can use to set a folder. I’ve noticed that when I run the applet in another language, text in the path control is translated. For example, this control points to the Desktop:
In English the folder name is “Desktop” and that hasn’t changed just because I’m running in French. Now, the path returned is correct i.e. it’s not translated. So, up till now this behaviour has just been a curio.
I’ve separately had trouble with code which tells Finder to open a pdf file. It works in English but when I run my applet in French it bangs this error:
Is it possible that these two behaviours are related ? I wonder why macOS is translating the name of the Desktop folder when in fact that name is still “Desktop” ?
UPDATE: I’ve checked and found that the second behaviour does not occur when using macOS 12.2.1 and earlier. But, it does when using the last release macOS 12.3.
What you see in the UI in the first instance is the localized name. To avoid problems, it’s best to use file objects (aliases, file references, NSURLs) where possible, rather than paths.
Shane, thanks. Not sure I understand. I’m not using localized text in the control – so, I guess macOS is doing that. Don’t know how to use a file object when I’m using the control to get a folder and the path to that folder. Luckily, the control returns the correct path which is what I need. The behaviour is a curio at present.
Anyway, I’m more concerned about the second problem and I’ll try your suggestion – I’ll send a file object to Finder instead of a string.
That’s right. It doesn’t matter what appears in the UI – the returned NSURL will be what you need.
In other words, Path Control gives you what to SHOW to the user (i.e. it may translate names and also remove extensions if the user has set preferences for that). You’re not supposed to use that to access a file on the file system.