Today, with smartphone apps outreaching a large number of people residing in different corners of the world, it has become vital for the app owners/developers to ensure flawless localization of the same. Localization or Internationalization plays a significant role in improving the overall user experience. It is the localization of the app that actually decides whether the same would be accepted by a big audience or not. In other words, greater the audience, the more sales or downloads will be achieved for the app. Through this blog, I'll be throwing some light on dealing with localization in iOS8 and Xcode 6. Hope the details covered here would assist you in understanding localization in a better way.
What
is the key difference between localization and internationalization?
Well, before
starting off with the process of localization in iOS8 and Xcode6, it is better
for all iOSApplication Development Companies to get acquainted with the key difference
between localization and internationalization. While on one hand,
internationalization refers to the process of designing an app for the
international audience, localization refers to the mere translation of an app's
user interface and resources into a variety of languages spoken across the
globe. Unlike the case of localization, internationalization is something that
can be performed by utilizing the in-built APIs for making modifications to the
code.
And
now, let's get going with the demonstration of localization in iOS8 and Xcode
Step 1- Gathering the sample data
Step 1- Gathering the sample data
For this
post, I'll keep the source of the demo data as the International Movie
Database(IMDB) which will allow us to attain the goal of displaying fine
details of movies using a variety of localizations. Here, it is crucial for you
to make the app dynamic and flexible in order to allow it to support additional
searching capabilities and a lot of other useful features. Although there are
plenty of ways for storing the movies data into the application, the one I
recommend is storing the data into a .plist file. The reason for this being
that it's quite convenient and less time-consuming to load data from a .plist
file to an array or dictionary via the already existing iOS SDK frameworks.
Step
2- Gearing up for display the data
Prior to
performing any “complex” localization tasks, it is essential for you
to ensure that the app is fully functional. For this, you can start by
implementing the display of the movie details in addition to the remaining
visual elements available in the base language i.e. English. It is interesting
to note that the data for each single movie in the .plist file is included
within an array and hence the first step would be to declare an array variable
to which the movie data from the file will be appended. Firstly, make sure to
select the ViewController.swift file in the Project Navigator. For this, simply
go to the top of the file containing all the IBOutlet properties and add the
below mentioned line of code:
var
selectedMovieIndex : Int?
Step
3- Use the NSLocalizedString Function
Prior to
proceeding ahead to the display of movies data, it is essential for you to have
a look at the most crucial function called NSLocalizedString. This is basically
the key for localizing text at any point of your specialized applications.
Here's the list of parameters that are accepted by NSLocalizedString function:
NSLocalizedString(key:, tableName:,
bundle:, value:, comment:
As
per the above parameters, the main concern is just the first and the last key.
While the key is a string value that's required for the app's translated
versions, the comment is basically a description to the translator.
Step 4- Pay attention to Numbers and Date Formatters
Numbers
and date, currency formatters play a vital role in the app localization process
in iOS apps. You need to take special precautions regarding number, date and
currency representation in the iOS application. Irrespective of how each
number, date, currency is stored in the app, the manner in which it is being
displayed must be well in accordance to the user's locale.
Step 5- Display the data
With
eight prototype cells in the table view, already added to the storyboard, you
can use each one of them along with an identifier value. You can use the
identifier values for dequeuing the correct cell in the tableView(tableView:,
cellForRowAtIndexPath indexPath:)
method, on the basis of the current index path's row value. In addition to
this, we 'll also be required to use the switch statement for specifying the
details of each prototype cell.
Step 6- Localize the Storyboard
For
each of the subview, Xcode will add a comment line that would comprise of the
following three things: Class of the subview, the normal title(text) that was
assigned to the subview in the Interface Builder and a unique object ID, that
is being used internally by Xcode for the purpose of matching localized strings
to the appropriate subviews. Moreover, also opt for localizing the strings,
images with the final task of compiling and running the iOS application.
Conclusion
With
that we're done with localizing each and every part of the application. Hope
you'd have liked going through the steps and found them easy-to-follow. Thus,
go ahead and start localizing your app to reach a wider group of targeted
audience.
About Author: Emily Heming is a savvy writer for xicom.biz,
a leading iPhone Apps Development Company from where you can find some of the
highly skilled and experienced iPhone application developers for hire.
COMMENTS