How to load localization storyboard string in ios with programmatically - ios

I am gonna to load localization string in storyboard with in application.
I want to know to load localization storyboard in IOS with dynamically.
in generally, in order to load localization storyboard, we must change language setup in phone or not we have to use another localize string file.
But I want to load string of localization storyboard in my app.
Namely, I use two button in app.
One is "English", another is "French".
if user click "french" button, then app has to load French's storyboard's string.

You can use NSBundle.The storyboard is a file in the bundle.

Related

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

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

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!

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

Default Xib get loaded instead of desired Xib?

In my Application I enabled the Localization for spanish Language . Sources like strings, Plist, Images etc are working fine without any problem except the xib files.
Instead of the xib of selected Language(spanish in my example) the View controller load default xib file
below is my bundle
And the screen shots of english and spanish Xibs respectively
EditViewController.xib(English)
EditViewController.xib(Spanish)
As seen in the above images I have translated the texts(in xib) into spanish for spanish xib
But the viewcontroller is loading same xib(default one) for both language. Help me to Show the desired xib.
Note:-
The Save Button on the top left corner change it's text to the selected language(I set the identifier type of that UIBarButtonItem to "save")
I think u have to change the language of your ipad or ur iPhone.
Your app should dettect that language and display the desired xib, on "EN" or "ES" folders.
The default folder that ios will use, is "EN" (English), so u can try to swap all files on "EN" to "ES" language.
Other opcion, is to use same xib for both languages, and use NSLocalizedString instead making 2 xibs.

Base Internalization without storyboard in XCode 5.0

I prefer not to work with Storyboard, so my projects start from an empty project, then in the appDelegate I write code like this:
MyViewController *VC = [[MyViewController alloc]init];
self.window.rootViewController = VC;
This intro just to tell you that if I try to activate Base Internationalization and I load the controller in that way I obtain just an empty controller. The xib seems not to be loaded.
Let's say that I want just to setup my project to be multi-language in the next future. So I don't add further languages, I keep only English.
These are the steps that I do to activate the Base Internat.
Selecting the xib file and pushing "Localize"
Localize it for the only Language available, English
From "Project" -> tab "info" I select "Use base Internationalization", selecting the only xib available.
Back to the xib, I activate the localizable string for English language (at the moment in the "Localization Box" of the xib I see "base" and "english". Eventually I add a Label to the xib.. just to be sure that the strings file will be created correctly.
Now, if I launch the App.... the xib isn't correctly loaded!
I hate this situation because it would be great to have this project setup for future translations... but it seems to work only if I work with a Storyboard.
Do you have some suggestions or have you experienced something similar with your projects?

Resources