How to open Specific language PDF based on Mobile Device Setting langiage

AppDeveloper 1 Reputation point
2021-04-06T12:35:30.463+00:00

Hi, I am working on Xamarin forms project. Could anyone help me with the below query.

I have 2 Pdf document in my App, one is in "English version " and other is "Chinese version". Based on mobile setting language , the pdf should open specific PDF.
Example.:
I have changed the Mobile device language to "English(as Default) , then PDF in english version should open . When I change mobile device language to Chinese and region to China then "PDF in Chinese should open.

Is this Possible to implement.? If yes How to do it.

Thanks in Advance.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,377 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 79,546 Reputation points Microsoft Vendor
    2021-04-06T13:39:05.523+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    You can use System.Globalization.CultureInfo.CurrentCulture; to get the Mobile Device Setting language, when you changed the language in android device, you need to re-start you application.

       public MainPage()  
               {  
                   InitializeComponent();  
                  
         
         
                   var s = System.Globalization.CultureInfo.CurrentCulture;  
                   if (s.ToString().Equals("en-US"))  
                   {  
                      // set English pdf  
         
                   }  
                   else if (s.ToString().Equals("zh-CN"))  
                   {  
                       // set chinese pdf  
                   }  
         
         
               }  
    

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.