160 likes | 189 Views
We received a new requirement from the same client whose project we had just completed. The mail read, “I want our application should change its language from inside application regardless of the phone languageâ€.
E N D
How to do Localization Inside your iOS App Irrespective of the Phone Language
Recently, while we were rejoicing the completion of an iOS app developmentproject with my team, an email intruded onto my screen. We received a new requirement from the same client whose project we had just completed. The mail read, “I want our application should change its language from inside application regardless of the phone language”. Did you guys ever come across this issue? Well, you might have! Hence, I thought of writing this blog to share my experience of how I resolved this issue.
In this post I would like to cover the following points: • What is app localization? • How localization works in iOS? • Why iOS app localization should be your priority? • How to do localization inside your iOS app? • Why localization matters?
What is app localization? App localization means adaptation of your application to meet the language, cultural and other requirements of your target market (a locale), as per W3C, the main international standard for World Wide Web. Localization is often written as l10n, where 10 is the number of letters between l and n.
How localization works in iOS? Once you launch an iOS app, the operating system makes an effort to match up or collate your preferred device language(s) with the language(s) supported by your app. Your app has a default language. For instance, English and French are the languages supported by your app and in this case, the user sets English as the app’s default language. So now when the users’ phone language is set to French then your app will display French content.
However, when the user changes phone language to Italian then your app will load the default app language which in this case is English. This is because your app only supports English and French and it doesn’t have Italian localization. So, in this case, your app will always display English content when the phone language is set to any language other than French.
Why should iOS app localization be your priority? Over the years, the iPhone sales worldwide have seen tremendous growth. Let the numbers speak for itself, see image below (courtesy: Statista). In the above graph you can see Apple iPhone sales worldwide right from the third quarter of 2007 to the most recent financial quarter. Apple sold 216.76 million iPhones in the 2017 fiscal year and 52.22 millionin the second quarter of 2018.
From 8 billion U.S. dollars in 2004, Apple’s revenue increased to more than 229 billion U.S. dollars in 2017 despite fierce competition in the smartphone market worldwide. And the credit partly goes to the iPhone success in almost all the countries. Now, you can expect your next customer to come from India, China, Mexico, Thailand or anywhere! Therefore, getting your iOS app localization strategy right could translate into more app downloads.
How to do localization inside your iOS app? When it comes to changing the language as per the phone then we generally take our phone language code and load the “lproj” file accordingly. But in this case it has to be dynamic, so I have created an extension of “String”.
Take a look at the code below: extensionString { publicvar localized: String { ifletbundleName:String = UserDefaults.standard.value(forKey: “USER_LANG”) as? String { let path = Bundle.main.path(forResource: bundleName, ofType: “lproj”) let bundle = Bundle.init(path: path!) returnNSLocalizedString(self, tableName: nil, bundle: bundle!, value: “”, comment: “”) } else { returnNSLocalizedString(self, tableName: nil, bundle: bundle!, value: “”, comment: “”) }
Now, when the user would change the language from app, their selection will be saved in UserDefaults with key “USER_LANG”. As soon as you call localized function, then from UserDefault key like “EN” or say “NL” will load along with proper bundle. In other words, if already “EN” language is selected and you change to “NL” then it will get stored in UserDefaults. And whenever localized function of String gets called it will load appropriate language translation, as shown below:
Now, when the user would change the language from app, their selection will be saved in UserDefaults with key “USER_LANG”. As soon as you call localized function, then from UserDefault key like “EN” or say “NL” will load along with proper bundle. In other words, if already “EN” language is selected and you change to “NL” then it will get stored in UserDefaults. And whenever localized function of String gets called it will load appropriate language translation, as shown below:
Why localization matters? I have mentioned here three key reasons why you must prioritize iOS app localization: 1. Reach out to the global market: With proper research and right localization strategy your app can dissolve geographical and cultural barriers and reach out to a wider audience. An extended customer base is always beneficial for your business. 2. Better engagement levels and UX: Customers would love to see the content fully adapted in their native language. Users getting real value out of your app in turn would boost engagement levels. The more engaged your app users are, the better it is for your business.
3. Create differentiation:When you upload your app to the steeply competitive app store then localization can help you differentiate from other similar ones and reach out to your target audience faster. Thus, app localization can lead to boost in revenue and help you get better ROI.
Summing up With iPhone sales gaining momentum in different countries over the past decade, localization could be a major factor influencing users’ download decisions. You can also take a look at the third party library shown below: https://github.com/PiXeL16/IBLocalizable Have you ever come across this issue of doing localization inside your iOS app? Did you find this post useful? I would love to hear from you; please share your thoughts by leaving your comments below.
Interested To Know More About? Outsource iOS App Development Mobile App Development iOS Application Development