Xamarin Unable to change language during run time(multi language app)

Srinath Mannam 291 Reputation points

Language localization isn't working for me. The app has been implemented with the

  • The user logs in and goes to the main menu. By default, the language will be selected as per the system (Let's assume it is English).
  • After logging in the user has a flyout menu option called language settings, where one can change the language. Let's assume he selected German over here.
  • Since the main menu is already rendered in English at the begining. Even if the user changes language in settings. The main menu doesn't update to the new language. It shows the English language only.
  • If the user navigates to any other screen which the person hasn't opened yet then that specific screen will have the newly selected language.

I am not sure why this is happening. Can someone help me with the same?

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

2 answers

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 37,111 Reputation points Microsoft Vendor


    I have a viable solution that has been tested in Android 10 and later.

    Here is the solution you can try it.

    Step1. After creating resource files, you need to create TranslateExtension.cs and Translator.cs in your project. The following is their code:


       public class TranslateExtension : IMarkupExtension<BindingBase>  
               public TranslateExtension(string text)  
                   Text = text;  
               public string Text { get; set; }  
               object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)  
                   return ProvideValue(serviceProvider);  
               public BindingBase ProvideValue(IServiceProvider serviceProvider)  
                   var binding = new Binding  
                       Mode = BindingMode.OneWay,  
                       Path = $"[{Text}]",  
                       Source = Translator.Instance,  
                   return binding;  


       public class Translator :INotifyPropertyChanged  
               public string this[string text]  
           // Here is the name of your Resource file.  
                       return AppResources.ResourceManager.GetString(text, CultureInfo);  
               public CultureInfo CultureInfo { get; set; }  
               public static Translator Instance { get; } = new Translator();  
               public event PropertyChangedEventHandler PropertyChanged;  
               public void Invalidate()  
                   PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));  

    Step2. You need to use this style Binding [Task], Source={x:Static vm:Translator.Instance}(the Task is a Name in your resource file) in your XAML file to binding.

    Step3. In your PickerEvent, for example, if you want to convert language to German, you can add the following code to the event:

       Translator.Instance.CultureInfo = new CultureInfo("de");  

    Best Regards,

    Alec Liu.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    1 person found this answer helpful.

  2. fabs cleanz 1 Reputation point

    But how to change the Flyout menu item texts? They remain the same.