Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode localize string Swift

I am trying to localize a string list. I have some photos, and for every photo a description of that, and I want to translate the description in another language.

That's the 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'd like to translate namelist category and sent message category, like this: "Description here 1" in "Descrizione qui 1", "Description here 2" in "Descrizione qui 2"...

What can I do? I am learning by myself to create an app because I have got some ideas, but I am stucked here... Thank you!

like image 688
MatteoAB Avatar asked Sep 30 '22 15:09

MatteoAB


1 Answers

You can add all localizations in your project info. The file is a key/value array. After in your code you can call in Objective-C

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

like

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

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

like image 164
houguet pierre Avatar answered Oct 03 '22 05:10

houguet pierre