Why is my main storyboard not picked up for localisation when I add a new language? - ios

I am starting to localise my app to other languages but when I add a new language in Xcode 9, only my launch screen storyboard is picked up for localisation not my main storyboard, I had expected both to be picked up for localisation, how do I get my main storyboard included for localisation?

Select your storyboard -> In file inspector there is a button "Localize", i believe that is what you need.

I wouldn't recommend localizing your app using Storyboard.
Why: In future, you won't be able to send a storyboard to the interpreter to translate it. It's slower and heavier. It takes more time.
Instead, there is another solution. Use NSLocalizedString to do localization. Then you will generate the file with translations and have 1 file for 1 language of the app. It's a common practice among developers and I always have been doing it that way.
Check out this tutorial it seems to be good from what I've looked through: link.

Related

is it possible to change the LaunchScreen Storyboard according to the country/region or default language of device?

i am developing an iOS app in which i want to show the LaunchScreen/SplashScreen according to the user's desired region or the default language of device amongst the other LaunchScreen stroyboards that i have made, i searched a lot but nothing much helped me so is this possible?
Thanks in advance!!
Who say It's not possible
Select project and add localization as below image
Add any language
Select desired storyboards
And here you can see storyboard for different languages.
---------------------------------- Test your localization --------------------
Edit your target scheme
Change Application language as below images and then run your app
Unfortunately this isn't something you can do.
According to Apple's documentation on Launch Screens, the launch screen should not contain any branding or text, so therefore can't be localised:
Avoid including text on your launch screen. Because launch screens are static, any displayed text won’t be localized.
If you want some localised text, you will have to present a custom view controller as your initial view controller as that will be localisable as any other view controller.
Yes, it is possible. See here
An iOS application should be internationalized and have a
language.lproj folder for each language it supports. In addition to
providing localized versions of your application’s custom resources,
you can also localize your launch images by placing files with the
same name in your language-specific project directories.
It's not possible.But you can mimic this scenario what just ankit said.
Keep the launch screen blank and didFinishLaunchingWithOptions function create a view controller with region specific content.
Below thread might help you.This was basically to add animation and your's quest was region specific but logic is same though. :)
how-to-add-animation-to-launch-screen-in-ios-9-3-using-objective-c

Localize several storyboards

I have a project which is relatively big, for such reason I use several storyboards. The thing is, I have not find the way to localize several storyboards in xcode. The options I see when using Base Internationalization are only related to my Main.storyboard and the LaunchScreen.storyboard files.
My app should be in english and spanish, those are the requirements. I have searched and searched but have not found the way to have .strings (english and spanish) for every storyboard, except the Main.
My storyboards are located in disk (and project structure) like this:
General_UI_Folder
Main.storyboard (with its .strings)
LaunchScreen.storyboard (with its .strings)
Subfolder1
...several .storyboards
Subfolder2
...several .storyboards
I'm using Xcode 8 and Swift 3.
I would appreciate any help, since I'm somehow new to iOS development.
You have 2 choices.
1) You localize each storyboard, using the storyboard localization system where it creates "substoryboards", 1 per language, where you change the value of labels, and other components, straight into the storyboards themselves.
You have to use this option:
2) Use the Localizable.strings files and update your view in every viewDidLoad method of your controllers.

Localization with NSLocalizedString or in .xib

I'm looking for an information that I haven't found on the Internet. I would like to know in which iOS version did NSLocalizedString appear ? (maybe it's here since the first version of iOS ?)
I also would like to know in which case using localization in the .xib and in which case using NSLocalizedString ?
I'm asking this question because I'm working on an iOS project using localization in the .xib files AND NSLocalizedString, and I don't really know why the two methods are used... (it's an old project, that's why I'm asking the first question ^^)
Last question, for a new project, which one of these two methods would be your preferred one ?
Sorry for all this questions, and thanks for the answer ! =)
Localisation using xib files is used when we want to localise elements on a UI e.g., when you want to show different images which has a localised text for a particular UIButton. You can achieve this using localised xib files.
There will be separate xib files for each language.
And when you are setting any text on the UI from you controller, NSLocalizedString.
I hope this helps.
NSLocalizedString was first available in 10.0
So I localize programmatically w/ NSLocalizedString because this way I can have all of my strings in one location.
Instead of through .xib localization generation, because with that you'll have a strings file for each xib you have.
However, if you have a .xib that you aren't modifying programmatically (i.e you don't have a custom class set as the file's owner), then you won't be able to programmatically set the NSLocalizedStrings. In which case, you will have to generate the strings files through the .xib.
Also, it is slightly more difficult to access string files associated with a .xib because it's directly connected with the .xib
NSLocalizedString exists since iOS 1.
Basically you need NSLocalizedString for all dynamically created strings.
In a new project I'd recommend AutoLayout and Base Localization.
There is one .xib file and all localizations – and layout adjustments – are performed at runtime via .strings files
Probably this question is dead but I jumped here searching for a method to localize xib strings and this page was the first result.
You can use both NSLocalizedString and xib. Have a look a this answer:https://stackoverflow.com/a/21443515/907720 discussed in detail here: https://medium.com/zendesk-engineering/ios-how-to-add-adaptive-constraints-to-support-a-universal-app-273663475b12

Localized Storyboard: How to add new content?

I just started to use Localization in my app. I now see that there are multiple "MainStoryboard.storyboard" files, for each language one. I can easily change the text.
But what happens when I want to extend the storyboard with a new view? I expected it to be duplicated into all storyboard files, but that doesn't seem to be the case?
Any suggestions?
Thank you.
You should be using Base Internationalization (see docs). The idea is to build up a flexible UI in your storyboards and then rely on Xcode / iOS to substitute in appropriate text. Instead of having a storyboard per language, you would have a single Base storyboard and a set of language strings files.

Maintaining different localized versions of interface NIB files

I'm learning the basics steps to internationalize an app and I have a question about localizing interface NIB files... I've seen that in Xcode you can click on a AppViewController.xib interface file and click on the + in the Localization section of the inspector window to add another language along with the default English one (I add Italian for example)... This allows me to translate the interface in Italian... but then how do you maintain future evolution of the App? If you need to add a button, for example, you have to add it by hand to all the localized versions of your interface NIB file? Documentation says also
Objects in a nib file typically have connections between them that should not be broken. Make sure you lock all connections before handing your nibs off to translation. For information on how to lock down your nib file, see “Localization” in Interface Builder User Guide.
Can you explain me this concept? I've seen the Localization Locking section within the inspector which allows you to lock Properties, Localizable Properties or Un-localizable Properties, but I don't understand very well what it does.
So, to sum up a bit, I'd like you to suggest me what is the workflow to design localized versions of your interface and maintain the multiple NIB files when the interface evolves.
EDIT: any idea and/or link that can help me?
iLocalize provides an easy way of localising an app and updating translated nibs. If you'd rather use ibtool, --localize-incremental, which will handle the changes in a nib and copy them to the translated nibs, is explained well here.
Alternatively, you could use NSLocalizedStrings and one nib which is useful in some instances. Set each control's title in code and you need only worry about making the controls wide enough for the longest translation.

Resources