Xcode localize Swift string

I am trying to localize a list of strings. I have several photos, and for each photo this is a description, and I want to translate the description into another language.

What code:

var imageList:[String] = ["new_york_city_sky_house_skyscraper_59212_640x1136.jpg","79506M1pZO4U6d12i0Xzf27765gWo71P5061732uthh68xHQ8Dq1yTQ0Bj8p9F45.jpg","iphone 5 wallpaper new york.jpg","New-York-Vintage-Effect-iphone-5-wallpaper-ilikewallpaper_com.jpg","Superb-View-Over-New-York-iphone-5-wallpaper-ilikewallpaper_com.jpg","New-York-Empire-State-Building-1136x640.jpg","New-York-City-iphone-5s-wallpaper-ilikewallpaper_com.jpg","new-york-city.jpg","New-York-By-Day-iphone-5-wallpaper-ilikewallpaper_com.jpg","The-Empire-State-Building-New-York-1136x640.jpg"] var nameList:[String] = ["1","2", "3","4","5","6","7","8","9","10"] var sentMessage: [String] = ["Description here 1", "Description here 2", "Description here 3", "Description here 4", "Description here 5", "Description here 6", "Description here 7", "Description here 8", "Description here 9", "Description here 10"] 

I would like to translate the namelist category and send a message category, for example: "Description here 1" in "Descrizione qui 1", "Description here 2" in "Descrizione qui 2" ...

What can I do? I myself am learning to create an application because I have some ideas, but I'm stuck here ... Thanks!

+5
source share
1 answer

You can add all localizations to the project information. The file is an array of key/value . After that, in code, you can call Objective-C

 NSLocalizedString(key:tableName:bundle:value:comment:) 

as

 var description = String(format: "%@ %d", arguments: NSLocalizedString("descriptionHere", comment: ""), 2) 

Here you can see a quick project with internalization. http://rshankar.com/internationalization-and-localization-of-apps-in-xcode-6-and-swift/

+4
source

Source: https://habr.com/ru/post/1204571/


All Articles