Reputation: 424
I used to localize my app using Localizable.string
files and providing a key for every text on my project.
Currently I'm working on a project using Xcode 9 and Swift 4 and for the first time I'm using Storyboards (yes, it sounds weird but I always used SpriteKit without using Storyboards) and I'm a little bit confused how to handle the localization with that. Basically my question is:
Should I use Storyboard localizations for UILabel
or should I implement everything in Localizable.string
and give the label a value through code?
Any tips in order to understand which is the best way to localize it?
Upvotes: 3
Views: 3360
Reputation: 143
One of the most reliable solutions I found, This exactly works for me .
1st we need to use a storyboard and create localization string file. which will automatically create ID to all the objects. Follow this tutorial
Then we can use one library MCLocaliztion which will pick respective translation string based on ID. What we have to do, we need to prepare a proper json based on Objects ID.
Hope it helps.
Upvotes: 0
Reputation: 69
There isn't a better/worse solution. It depends on the purpose of your UILabel
. If it's an element that doesn't change during lifecycle of the app, you may prefer using directly Storyboard localization. Instead, if the label could have different values, I recommend you to set programmatically your localized strings.
Upvotes: 0
Reputation: 4383
I recommend you to use Localizable.string
instead of Storyboard localizations, because ids of the labels in storyboard might change.
Upvotes: 2