Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Storyboard Localization Duplicate Strings Merge?

I am currently working on an iOS app and localizing it into multiple languages but have faced an annoying (not breaking) issue.

When i would add a new localization for my storyboard xcode will automatically populate the strings, which is very nice. The issue i am having is that i have multiple interfaces which both have a back button. The text on these is of course the same and their translations are as well. The question i was wondering about, is it possible, without using strings.localizable, to somehow merge multiple object translations into one?

This is how it would currently look:

"Pnu-Ec-HAj.normalTitle" = "Back";
"Rtx-fT-rdc.normalTitle" = "Back";

But it would be way easier if there was a syntax such as

"Pnu-Ec-HAj.normalTitle", "Rtx-fT-rdc.normalTitle" = "Back"; (this syntax is not correct obviously)

I have looked around quite a while but have not found any answers to this question yet.

Thanks for reading.

like image 489
Guus Avatar asked Feb 18 '16 13:02

Guus


1 Answers

I'd recommend referencing every text in your storyboard in code, and setting the text on viewDidLoad like, e.g.:

buyButton.titleLabel.text = NSLocalizedString(@"SHOP_BUY_BUTTON_TEXT",@"Button for buying product in detail view");

It's loads of work if you have huge storyboards, but in the end you have a clean Localizable.strings with concise keys and comments, providing necessary context for your translators.

I prefix the key with the section of the app, so for example SHOP_***, USER_SETTINGS_***, etc.

In addition, we use a service like OneSky to organize our translations online and update them from the cloud (not affiliated with them, and it's not without its teething problems either).

like image 200
Julian Vogels Avatar answered Oct 13 '22 14:10

Julian Vogels