Support Multiple Languages In Xamarin.Forms Application


In this article, we are going to make an application through which we can support multiple languages in our Xamarin.Forms application. We are going to achieve our goal through globalizing the Xamarin.Forms code by adding and using string resources in PCL project.


Firstly, create a Xamarin.Forms PCL project. If you are new to Xamarin then go to this link to learn to create a Xamarin.Forms application. Here I assumed that your project is created and ready to develop this sample project.

After creating PCL project, now we are going to add a resource file which contains string resources to be used in our application.

Click on Add New Item >> Resource File. Rename it and click "Add".


Now, add some resource in your resource file which we are going to use in our application. Here, you are going to add a resource name, its values, and comments. After this, change the access modifier of the resource as public, as shown in the picture.


So, here our default resource file is created. Now, make another resource file in the language you want to support in your application. The naming convention of the other supportive language must be started from the default resource file name followed by “.” And then use language specific code, just like this

  • - French language translations.
  • - Spanish language translations.
  • - German language translations.
  • AppResources.ja.resx - Japanese language translations.
  • AppResources.zh-Hans.resx - Chinese (Simplified) language translations.
  • AppResources.zh-Hant.resx - Chinese (Traditional) language translations.
  • - Portuguese language translations.
  • - Brazilian Portuguese language translations.

Now here, we are going to support Spanish in our application. So, make the other resource file with a name as “”.


Now, with the same name, write these values in Spanish. So, our file will look like this. And don’t forget to make it public.


So our Spanish file contains Spanish translation. Now, use this resource in XAML page.


  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <ContentPage xmlns=""  
  3.              xmlns:x=""  
  4.              xmlns:local="clr-namespace:CSharpCorner"  
  5.              x:Class="CSharpCorner.MainPage"  
  6.              xmlns:Resource="clr-namespace:CSharpCorner"    
  7.              >  
  9.     <Label Text="{x:Static Resource:ApplicationResource.BodyText}"   
  10.            x:Name="label"  
  11.            VerticalOptions="Center"   
  12.            HorizontalOptions="Center"  
  13.            FontSize="Large"/>  
  15. </ContentPage>  

You can also set the resource from C#.


  1. using Xamarin.Forms;  
  3. namespace CSharpCorner  
  4. {  
  5.     public partial class MainPage : ContentPage  
  6.     {  
  7.         public MainPage()  
  8.         {  
  9.             InitializeComponent();  
  10.             label.Text = ApplicationResource.BodyText;  
  11.         }  
  12.     }  
  13. }  

Now, to test our application, change the mobile language to Spanish and you will see some Spanish text; otherwise, the default English text is shown.


Xamarin Xamarin

In the first emulator, the English language is set as default, whereas, in the second emulator, the default language is set Spanish.  This means that the application is using our Spanish resource file to show the text.

Up Next
    Ebook Download
    View all
    View all