Localizing non-root InfoPlist values
Asked Answered
B

1

6

I'm attempting to add localizations to values that appear in my Info.plist file. I'm having no trouble doing this for top-level keys using an InfoPlist.strings file. But, I cannot figure out how to get it to work for non-top-level values.

For example, the CFBundleDocumentTypes is an array of dictionaries. I need to localize each array's CFBundleTypeName key differently. A similar situation exists for UTExportedTypeDeclarations/UTImportedTypeDeclarations, with the UTTypeDescription key.

Apple's documentation on UTTypeDescription specifically says that it can be localized with an InfoPlist.strings files. And I've tried, but have not been successful.

As reference, I tried to refer to Apple's own apps. The only one I was able to find that uses any non-root keys was Xcode, and Xcode isn't actually localized to anything other than English. I cannot be sure if its approach actually works. And, there's at least some strangeness within Xcode's bundle, because there are keys that appear in its InfoPlist.strings file that aren't actually in the Info.plist itself.

Does anyone know how (or if) this can be done?

Brierwood answered 24/9, 2019 at 19:22 Comment(2)
Did you figure this out? Have the same issue.Pooley
I have not, and for now I've moved on. But, your comment has reminded me to try to look into it again.Brierwood
B
4

Real life example with my own app. If you have an exported type with this:

<key>UTTypeDescription</key>
<string>CreaPhoto document</string>

My French translation in InfoPlist.strings is:

"CreaPhoto document" = "Document CréaPhoto";

It seems so dumb a "duh yeah of course" moment, but this is totally different from everything else in the info.plist translations, where you are expected to put the key when it's in root. No donut to Apple for not explaining this in their page.

Things to add in macOS: you must increment your Bundle ID each time you modify this (38 to 39 to 40 to 41 to 42 ...), you must build your new version, execute it in debugger (or release), and you must logout and logon so it gets taken into account.

There are ways with less steps, but this is the safest sure-fire way I found to get it applied in Finder.

Bobbi answered 1/2, 2020 at 2:40 Comment(1)
The only place so far I've seen Apple document something similar is for a different key in Service Properties: NSMenuItem. Cmd+F for the text "create a .strings file that has Send Selection as the key".Downe

© 2022 - 2024 — McMap. All rights reserved.