Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you localize static UIApplicationShortcutItems?

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?

like image 921
Wayne Hartman Avatar asked Sep 25 '15 00:09

Wayne Hartman


People also ask

How do you localize in Swift?

Click on iOS->App/Single View App->Next. Name your project and select the language as Swift. Select a desired location and click on Create. To start with Localization, click on your Project Name -> go to Info Tab -> Under Localizations, click on the '+' button.

How do I localize Xcode?

Tell Xcode to put it there by selecting it in the Project navigator, then clicking Localize… in the File inspector. Xcode will ask you to confirm the file's language. The default will be English since that's your development language. Click Localize.


2 Answers

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"; 
like image 61
Wayne Hartman Avatar answered Sep 22 '22 22:09

Wayne Hartman


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

like image 37
Dipen Chudasama Avatar answered Sep 23 '22 22:09

Dipen Chudasama