question

AppDeveloper-9291 avatar image
0 Votes"
AppDeveloper-9291 asked LeonLu-MSFT edited

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

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.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT edited

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.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@LeonLu-MSFT
Thank you, What about in iOS

0 Votes 0 ·

You can use above code in xamarin.forms directly, it worked in iOS as well.

0 Votes 0 ·

@AppDeveloper-9291 Did you try to use above code, is that worked in iOS? I test it in ios 14.4, it worked.

0 Votes 0 ·