I am working on a project where we need to provide localisation support - (Localisation is provided based on user choice not based on System Settings. ). I have provided localisation support in storyboard and base localisation is also provided.
I was able to get the strings in TextFiled localised using the below code
var languageBundle =NSBundle.FromPath (resourcePath);
var storyborad = UIStoryboard.FromName ("MainStoryBoard", languageBundle);
storyborad.InstantiateViewController ("ViewController");
But the images are not shown at all irrespective of language.
I have placed all my images directly in the Resource folder.
Is there any way to show the images ? Is am missing any information that need to added in the bundle when initiating the story board.
I am new to iOS Development.
I was not able to get exact solution to this problem but i was able to do a workaround. Placing images under the respective locale folder could resolve this issue.
I am using Xamarin studio for development so when i added the required images as links, some times it shown a positive result.
Related
TLDR: Xcode generated storyboards for each language, however I want the "old"(?) *.strings files. How?
I am currently in the process of localising my storyboards. After I enabled everything, Xcode generated another storyboard alongside the original (english) one for me to localise. I was surprised, I expected a Localizable.strings file, like the apple documentation still states as of April 3, 2021:
For storyboard and XIB interfaces, select the user interface files (files with a .storyboard or .xib filename extension). Xcode adds a strings file to the localization folder that contains the text to translate, as well as comments that describe the user interface components. For example, if you add German to an iOS app that uses storyboards, LaunchScreen.storyboard becomes a group containing a LaunchScreen.storyboard (Base) and LaunchScreen.strings (German) file.
I searched around the internet, in apple developer forums, watched both WWDC18 and 19 talks about localisation in Xcode, but did not find a single mention of translated storyboards.
After the initial translation, which works great due to the simplicity of just filling everything in, it gets frustrating however, since every layout change needs to be repeated for every language. This can't be intended, there must be a better way, right? Sadly, I didn't find anything. Even a hint to a piece of documentation regarding these storyboard copies would be greatly appreciated. Thanks!
There are some screenshots of the possibility to convert these two formats via a dropdown, like the third picture in this post. However for me, there is no dropdown next to the language item when I click the storyboard, neither on the group, nor individual base or localised ones:
Is this a bug or am I missing something here? I am using macOS Big Sur 11.2.3 with Xcode 12.4 (12D4e).
Turns out, you need to use the Base Localization feature, the dropdown then appears and you can convert existing storyboards to *.strings files.
I have 2 storyboards each with 2 StoryboardName.string (English and French) and a separate Localize.string that contains the string for the view controllers.
When I run the app on an iPhone it's picking the localization files correctly, but on the iPad it keeps the declared values in the storyboard without useing the values fron the files.
I have tried to delete and install the app multiple time, also I have tried to set a parameter from the scheme configuration, I checked the id's from the localization file to be in the storyboard (and they are). Nothing work...
I modified the localization files but the iPad it's not picking the changes.
How can I force the iPad to chose/use a localization file?
see the target is properly set or not on right side window
The problem was that an " was missing from the storyboard.string files and xcode was not throwing an error. Also I have changed in the scheme at option the application language and the application region.
Helpful tutorial:
http://rshankar.com/internationalization-and-localization-of-apps-in-xcode-6-and-swift/
Android has very good tools for creating different variants of an app (for example, the exact same code but with a different logo). You just create a different flavour and put a different image for each flavour's directory. How do I achieve this in Xcode? The information I have found on the web is very bad. I tried creating a new target for my project but that created a new storyboard, AppDelegate etc. It just created a new app altogether. I want different resource folders for different brands of the app. I'm using Swift.
You're not likely to get the same kind of setup you could have with Android. There are a bunch of features you could use individually or in combination. rmaddy's comments are good. Another option is creating additional schemes and setting the properties of the project for each one. The important thing to keep in mind is that the simplest solution may not look the way you're expecting.
I was wondering if somebody could explain in the details how I can localize an iOS app using only 1 storyboard. I know how to localize by creating several storyboards(one storyboard for each used language), however I'd like to find out another solution.
Thanks.
The tutorial on raywenderlich.com uses two forms of localization together. The reason is he also checks the storyboard when turning on localisation in image 3:
.
So then what?
NSLocalizedString is very useful, any text set programatically can (and should) be localised using this method. Ray's tutorial is still very useful.
However, it's not very desirable to create a clone of the storyboard(s) to do translation, it's just not very maintainable in the long run.
And what about storyboards?
The magic happens using the Base Localization feature. Base localization uses the generated objectId's to 'map' different languages to the storyboard.
Do note that this feature is only available using SDK 6.0 and above. Running the app on a lower iOS version will not cause any errors, it'll simply won't work.
Go to your project, and select Base Localization, then add any other language.
Open your storyboard file and check the new language as well. Note the icon is not a storyboard icon, but a simple text file icon. That's a good thing; it won't copy the whole storyboard this time :).
Note how there is now another file 'under' the storyboard. Xcode automatically generates a file for every language you select.
You can se Localization feature for this. You need to add the Localizable.strings file for each supported language and use it for locaization.
You need to use : NSLocalizedString() for fetcing data corresponding to each key.
Check this tutorial for details.
I am working on a tutorial and something interesting caught my attention. I just created a Single View Application Project and I noticed two .xib files, one named ViewController_iPhone.xib, one named ViewController_iPad.xib. In my projects, if I wanted different .xibs for iPhone and iPad I would use ViewController.xib for iPhone and ViewController~ipad.xib for iPad. I kind of understand that this may be a new naming convention, but can I use this naming convention event if I target older iOS versions?
Also this happens in xCode 4.6
Thank you.
I Think you might have come across universal applications on iOS , or might loading .xib files according to the device . Either way you should use ~ipad instead of ~iPad and ~iphone instead of
~iPhone for it to work correctly.
Both will work alike on simulator but the prior will ditch on device.
PLease Find the extract from Apple reference for iOS Supports Device-Specific Resources
iOS Supports Device-Specific Resources
In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device. This capability simplifies the code you have to write for Universal applications. Rather than creating separate code paths to load one version of a resource file for iPhone and a different version of the file for iPad, you can let the bundle-loading routines choose the correct file. All you have to do is name your resource files appropriately.
To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format:
.
The string represents the original name of the resource file. It also represents the name you use when accessing the file from your code. Similarly, the string is the standard filename extension used to identify the type of the file. The string is a case-sensitive string that can be one of the following values:
~ipad - The resource should be loaded on iPad devices only.
~iphone - The resource should be loaded on iPhone or iPod touch devices only.