How do you localize static UIApplicationShortcutItems?
Asked Answered
R

2

34

I have an application and I want to add a mix of static and dynamic app shortcut items. Localizing for dynamic items is pretty straightforward, using NSLocalizedString, but not so much with the items in your info.plist. I already have an InfoPlist.strings file for localizing the name of my application, but I am less sure about how static UIApplicationShortcutItems would work since these items do not have a unique key.

How do you localize static UIApplicationShortcutItems?

Revest answered 25/9, 2015 at 0:53 Comment(0)
R
55

Turns out that the app will search the InfoPlist.strings file for a corresponding key matching the value in the Info.plist. That might sound a little confusing, so here's an example:

For the UIApplicationShortcutItemTitle key in the info.plist, add a value of, say, ADD_ITEM_SHORTCUT_TITLE:

<key>UIApplicationShortcutItemTitle</key>
<string>ADD_ITEM_SHORTCUT_TITLE</string>

This value will then need a corresponding entry in your InfoPlist.strings file:

ADD_ITEM_SHORTCUT_TITLE = "Add Item";
Revest answered 25/9, 2015 at 2:17 Comment(5)
This no longer works on Xcode 8 beta 6 ... Any one else figured out what the alternative is?Confect
@Confect I am unable to reproduce your issue on Xcode 8 beta 6. Are you sure that you have everything setup correctly? You might consider asking a new question.Revest
Yes .. it was my bad. Our team did localization and split the files but didnt copy this over. It does work on Xcode 8 beta 6Confect
Create a new infoPlist.strings file is necessary. I added the localization string another string file :(Solorio
Yoiu don't need to write ADD_ITEM_SHORTCUT_TITLE as this also seems to work: "Add Item" = "Add Item";Activate
C
21

Add one new string file and save it with name "InfoPlist.strings" enter image description here

Enable Localization for this file, and add string with title like below explanation.

enter image description here

Now Open your info.plist file and add title like below.

enter image description here

Christoforo answered 7/10, 2015 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.