iOS is there a way to assign Localized String to a UILable from IB/storyboard - ios

I want to assign NSLocalizedString(key, comment) to a UILabel from storyboard without creating an outlet for it.

Just select your storyboard/xib, go to File Inspector. In the Localization part, you can tick the language you want. Then, it will create a .string file with all text used in storyboard. You'll just have to provide a translation for each text used in storyboard.
If no language appear in this part, you have to change values of Localization native development region in Info of your project.

This might help, the official Apple guide to translating storyboard texts. I found it pretty straightforward. I am currently translating texts in-code, in the storyboard and in my info.plist files without issue. Hope it helps!

Related

Is it possible to remove a UILabel from localization?

Hello localisation pros,
after searching the various tutorials, tipps and tricks around "Localization" and of course this stackoverflow forum, I have to commit, that I did not find a good answer. Thats why I post my problem here and hope for an answer.
I have two types of UILabel in my Storyboard. And I have plenty of each type in the app.
One type contains text, that is not necessary to localize, because it is just an integer (e.g. "5"), or an emoji or it is just an international word (e.g. "Computer").
And of course I have the other type of UILabel in my app, that contain text, that must be localized.
When exporting for localization, ALL UILabel in the Storyboard will be put in the localization files by xCode and makes the file bigger than necessary, since plenty of the UILabels belong to type 1.
Is there any way, to take out these UILabels from the localization process and to mark them as "not necessary to localize" ??
Thanks for helping.
You need to manually remove the each label entry from localize file as Xcode localize whole storyboard not single one or you can create xib of each viewController the you can localize each viewController .
Thanks
Change them to attributed and they won't get exported.

Xcode when adding localization not all storyboards are found

When I try to add localization to my app by clicking on project-> localization -> + and add a new language the popup will only show two storyboards even though my app has three.
One storyboard file is missing from the popup
You need do following steps :
First you need to create new string file.
after select this string file and In file inspector and click on Localize button .
then you can see string file along with storyboards.
Adding Localizable.strings is a needed. If you still don't find some storyboards when adding a language, select the storyboards that don't appear and click localize button on the File Inspector in the right pane. Now when you add a new language the popup will show those missing storyboards
I had to open my storyboard and add a base localization, then it would show up in the popup when I wanted to add a new language

Trouble in Internationalisation, iOS

I need to internationalize some of the labels in a screen; do I need to localize the whole screen?
One more doubt, I have taken a string file and pulling the value of the keys from that file directly from that file using NSLocalizedString, then also do I need to localize the screen or it will by default get localized?
Thanks in advance.
you need not to localize the whole screen.
for two label only, on viewdidLoad
self.lbe1.text = NSLocalizedString(#"Label1", nil)
self.lbe2.text = NSLocalizedString(#"Label2", nil)
your second doubt is not clear to me.
You have to create the localize file. Then label you can use the localized id. Then you don't need to worry the whole screen or particular screen or particular text. Because whatever you can change. If you want more info refer this link
http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014

xcode 6 iOS launchScreen.xib localization issue

In my app I have three languages. The launchScreen.xib has three localzations too.
Like the localizable.strings I changed the text that should be used by the Object-ID.
When launching the App there is always the english text used, not the localized. And there is a "X" int he symbol of the LaunchScreen.xib and LaunchScreen.xib (Base). Why? How can I solve that issue?
The correct answer to specifically localizing the launch screen is here:
Localization of Default.png is not working
And for shortcutting I'll paste the main steps:
Create InfoPlist.strings file. (File,New,Resource,Strings)
Localize it and add the key "UILaunchStoryboardName" with the value being the name of the xib you want to be shown as the launchscreen for that localisation.
For e.g. for the Spanish version, add your launch screen key and name for the Spanish version of your Launch screen in the newly created InfoPlist.strings localized for spanish.
"UILaunchStoryboardName" = "Launch_es";
As Apple's document, launchscreen will never locale your text:
"Avoid including text on your launch screen. Because launch screens
are static, any displayed text won’t be localized."
https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/
I would like to give clear description of fix according to previous info.
I got the same issue and couldn't find clear description. I have Xcode 8.2.1 and Swift 3.0 now.
Finally:
I copied LaunchScreen.storyboard and added it to project with name Launch_ru.storyboard. After I did localization of Launch_ru.storyboard.
Next need to choose it and add Base Localization.
Next need to add to added during main localization file InfoPList.string key "UILaunchStoryboardName" = "Launch_ru";
where Launch_ru is name of my new Launch_ru.storyboard.
These three actions fixed my issue.
Fawkes' answer is the right one:
Create InfoPlist.strings file. (File,New,Resource,Strings)
Localize it and add the key "UILaunchStoryboardName" with the value being the name of the xib you want to be shown as the launchscreen for that localisation.
One thing to note is that, all the launch screen storyboards that you'll end up having need to be barked as "Base localization" in the Files Inspector:
If you accidentally mark them as a localization for a different language, it will not work (it will just display a black screen!)
I had same issue, after that i used MCLocalization it is very easy to integrate in your app. It worked perfectly for me

How does waze change objects location with their localization?

The first image is when the language is set to Hebrew, the second is in English. Look at the word " Thanks: " in the image. How Waze managed to change the location of the word to a Right To Left language? With regular localization
Thanks:x
should have been
תודות:X
That's just one example. Waze does that a lot.
Waze supports iOS 4.3 and later so AutoLayout is out of the question. With regular localization I know you can change the content of the word but location? that's a first.
Can I set an if iphone language is English then change the layout to..? (if so that's a lot of ifs.."
Thanks
Frankly, I do not know if there is any standarized way of doing that.
But I see several options:
1. Using localized .xib files or even full storyboards.
2. Changing that programmatically. Get the current localization and add some IFs to the view controller and re-arrange the items. If this is in a custom UITableViewCell subclass then overwrite the layoutSubViews (or so) and change the layout accoring to the locale settings. If you layout it within cellForRowAtIndexPath then apply the localization there.

Resources