Xamarin Mobile App With Localization Support
by Vijay More, Hemlata Tiwari 29th Apr, 2015.
Xamarin.Forms is Xamarin’s new cross-platform UI framework that allows you to build user interfaces for iOS, Android and Windows Phone using XAML. With Xamarin localization feature we can develop mobile app in multiple languages.
In this document, we will see how to localize our app using the common .resx files across all three platforms: Windows Phone, iOS, and Android.
Objective
If mobile app is only available in English then there is a large untouched market of potential users who can't or won't use the app since it's not available in their preferred language.
Localization is the process of translating all of the text labels (strings) in the app to the preferred language. The input data will be stored as per the mobile culture.
Steps to provide Localization in Xamarin.Forms
- Create Xamarin.Forms project
- Setup the PCL project
- Include multiple resource files in PCL project which is used to display different strings according to the Current Culture of Device.
- Create "Dependency service" of Xamarin
- It is used to get the device/platform specific culture and according to that culture "ResourceManager" class load that particular culture’s Resource file.
Below image shows how different resource files are included in PCL project.
Code Snippet
Create .resx file for Germen language:
Get Current culture:
Bind Localization in XAML: