Localized Storyboard: How to add new content? - ios

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.

Related

Can Xcode Add Items To A Storyboard, In Editor, Through Code? [duplicate]

So far I have seen documentation of how to write a storyboard with Interface Builder. I prefer writing the code manually though. Can a storyboard be developed manually without interface builder in xcode?
I would not recommend this, however, if you right click on your storyboard file in the Project Navigator choose the option Open As > Source Code you can hack away to your heart's delight.
I would imagine you'd prefer editing a Storyboard using IB as you'll just be creating more work for yourself debugging various syntax issues that the editor would have abstracted away for you. Note, that the XML is compiled at build-time into the binary files called nibs, then loaded and instantiated at run-time to create the views. Getting your hands dirty with that will slow you down.
https://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/Edit_User_Interfaces/edit_user_interface.html#//apple_ref/doc/uid/TP40010215-CH6-SW1
BTW #Kenny's suggestion to write your views in code is a good one if you really don't want to use XIBs or Storyboards
If you prefer writing code, I would suggest doing everything programmatically and not using storyboards at all.
Do you use a text editor to write text files? Then use the storyboard editor to write storyboards.
At the end of the day, if you wanted to reverse engineer a storyboard file you could do that, and then hard code your own, new one using what you've learned.
Here's a clue: XML.
Alternatively, ignore storyboards completely, and just programatically create all your views, segues and transitions. That is perfectly feasible.

How to override values/file in framework in ios

I have developed the application in ios. It is working fine. I have converted it as a framework(library) so that My codebase remain same.
I have multiple clients for this app. So I need to change the following things
Colors (As it will change the background colors, text colors etc)
Strings (Like headings and labels in some views)
Some files like Images etc
What I want:
As I am android developer, So in that I can create another color file in my client app with same color name, that replaces the color value in Library. and this it just require only one file to be replace and it automatically overrides in library. Same was the case with the String.xml and image files
Looking for something like that as I have described above.
What I searched and found so far:
After searching alot I have found that I need to make outlets public and then I can give them color by accessing them. But What If I have a 1000 of views and 1000s of outlets to make to use this technique, Isnt it better to use it as same way as in android I described above.
Confusions:
Is there anyway in IOS to declare color in a file and to use them in IB and code as well. Well I read about Color.xcassets but that is for ios 11 I think
How to make strings file and to use them in IB and in code. Like strings.xml file in android?
So I short, I want to updated colors,Strings and file per client wise and I do not know how to do it and what is a best way of doing this??
Please help and thanks in advance. Please share your views.
You should configure your framework to read from predefined files in .plist file. this will require only changing the files content in the client application.
Easy way to handle colors and theme using SkinKit. This is too old code. You just reuse idea or create custom themes configuration file(plist,JSON),Strings and images as .bundle read all color and customization from that bundle. So easy to change Colors, Strings and Images assert for various clients.
You seem to have a misconception about what IB is — in particular, what a nib is, and what it means to edit a nib, which is what Interface Builder does. A nib is a file expressing potential instances, typically views. You edit it on your computer using Xcode (IB). When your app runs, the nib is loaded and the views are actually instantiated. That is the only thing you can do with a nib when the app runs. You cannot modify the nib in some way when the app runs; all you can do is load the nib and get the instances.
So, if you want to change all the titles of buttons or all the colors of views when your app runs in accordance with some configuration file, you can do that, but that has nothing to do with nibs or IB. You would just load the nib as usual to get the views, and then change them all, one by one, in code. You could use tags or some other identification mechanism to help you find each view, but that would be entirely up to you to work out.

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

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.

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

Resources