Introduction:
In this tutorial, we will learn how to implement Multi-Lingual in Xamarin.Forms without using external plugins or platform wise implementation with dependency service. The latest Xamarin forms offers .net standard to implement the multilingual and without further delay, we will skip into the coding part of the article.
Coding Part:
Steps:
I have split the coding part into 4 steps as in the following.
- Creating new Xamarin.Forms Projects.
- Creating App Resource files for multi-language.
- Language Management
- Implementation of Multi-Lingual.
Step 1: Creating new Xamarin.Forms Projects
Step 2: Creating App Resource files for multi-language
- Add one resource file as base file with the name your preferred name. In my case, I kept the name of the file as “AppResources.resx” and it will be used as default language file.
- Then add one resource file for each language you want to support. We must follow a specific naming convention for each file as the base resources file followed by a period (.) and then the language code.
- For Example
Language Language Code File Name Tamil ta AppResources.ta.resx French fr AppResources.fr.resx - Then add resources with the same name with language specific values in each resource files as like in the below screenshot.
Step 3: Language Management
In this step, we will see how to handle the multilingual for Xamarin.Forms.
-
Get Device Language
CultureInfo.InstalledUICulture
-
Get or Set the actual language
CultureInfo language = new CultureInfo("ta"); Thread.CurrentThread.CurrentUICulture = language; AppResources.Culture = language;
Step 4: Implementation of Multi-Lingual
- Open your designer file and add the resources as shown in below code snippet.
<?xml version="1.0" encoding="utf-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:resource="clr-namespace:MultilingualXFSample.Resources" x:Class="MultilingualXFSample.MainPage"> <Label Text="{x:Static resource:AppResources.WelcomeText}" FontSize="Large"/> </ContentPage>
- By default, the app will take the base resource file. By passing the language code will takes the language specific resource file and we can set the language as shown in below code snippet in runtime
CultureInfo language = new CultureInfo("ta"); Thread.CurrentThread.CurrentUICulture = language; AppResources.Culture = language; Application.Current.MainPage = new NavigationPage(new MainPage());
Output
Default - English | Tamil | French |
This is really a great Article for those who are looking for Discount coupons, cashback offers on online Mobile shopping sites in india.
ReplyDeleteThanks for sharing the wonderful information and Save you huge money & time. More offers and coupons Visit
Mobile Offers
Today Mobile Offers
Mobile Phones
Mobile Offers In Flipkart
Latest Mobile Offers
Mobile Offers In India
Realme Mobile Offers
Mobile Phones Under 10,000
Amazon Mobile Offers
Flipkart Mobile Offers
Up Coming Mobile Offers
Very detailed and informative!!
Keep On Sharing....
This is really a great Article for those who are looking for Discount coupons, cashback offers on online Mobile shopping sites in india.
ReplyDeleteThanks for sharing the wonderful information and Save you huge money & time. More offers and coupons Visit
Mobile Offers
Today Mobile Offers
Mobile Phones
Mobile Offers In Flipkart
Latest Mobile Offers
Mobile Offers In India
Realme Mobile Offers
Mobile Phones Under 10,000
Amazon Mobile Offers
Flipkart Mobile Offers
Up Coming Mobile Offers
Very detailed and informative!!
Keep On Sharing....
Thanks for a marvelous posting! I quite enjoyed reading it, you may be a great author. I will ensure that I bookmark your blog and will eventually come back very soon. I want to encourage yourself to continue your great posts, have a nice day!
ReplyDeleteMobile Phones, Mobile Offers Today, Mobile Phone Offers,
realme mobile phone price, realme mobile phones
Very detailed and informative!!
Keep On Sharing....
Great Article
ReplyDeleteandroid based projects
Java Training in Chennai
Project Center in Chennai
Java Training in Chennai
projects for cse
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Serves24 is Best Air conditioner repair In Hyderabad We Provided Door Step Repair And Service & Provide best in class. Get 6 months repair guarantee. Book Now just @249/-. at most affordable prices
ReplyDeleteair conditioner repair services
air conditioner repairs services hyderabad
air conditioner repair hyderabad
air conditioner repair services
Mua vé máy bay tại Aivivu, tham khảo
ReplyDeletekinh nghiệm mua vé máy bay đi Mỹ giá rẻ
cách đăng ký chuyến bay từ mỹ về việt nam
đăng ký vé máy bay từ nhật về việt nam
thông tin chuyến bay từ canada về việt nam