changing cultureinfo on android using xamarin and c#

xamarin forms localization
c# currentuiculture vs currentculture
xamarin forms change language

Im calling a custom method to dynamically switch the current cultureinfo to french "fr"

Like this but after calling that method my android app still use the default culture which is 'en' but in debug mode the culture seems to be ok. My folder are ok. I have both and the string values are configured. folder: resource/values/strings.xml, resource/values-fr/strings.xml.

Do I need to reload my contentview or something? what do I miss here?

    private void SetLocal(string lang) 
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang);
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);

I know it's a bit late to answer this question but I found the solution!! Try this it works for me:

 string cultureName = "fr-FR";
        var locale = new Java.Util.Locale(cultureName);
        Java.Util.Locale.Default = locale;

        var config = new Android.Content.Res.Configuration { Locale = locale };
        BaseContext.Resources.UpdateConfiguration(config, BaseContext.Resources.DisplayMetrics);  

C# Copy. using System; using System.Globalization; using System.Threading CurrentUICulture = new CultureInfo("pt-BR"); // Change the current UI culture to  I am new to xamarin android I have given up on forms and I am wanting to change layout onnavigationselecteditem and was wondering if someone can point me in right direction I tried using setContentView but that did not change the view at all.

I can't test it right now, but try this:

        Resources.Configuration.Locale = new Locale(lang);
        Resources.UpdateConfiguration(Resources.Configuration, Resources.DisplayMetrics);

In Windows this is easy, I create a new cultureInfo, and set the UI and I have tried this on the Android, and it seems to only last until the activity changes. NET for Android", but more like a C# wrapper around Android, and ". At run time, ASP.NET uses the resource file that is the best match for the setting of the CurrentUICulture property. The UI culture for the thread is set according to the UI culture of the page. For example, if the current UI culture is Spanish, ASP.NET uses the compiled version of the file. If there is no match for the

All this in the MainActivity

using System.Threading;
using System.Globalization;

void SetLocale() {

    CultureInfo ci = new CultureInfo("es-US");

    Thread.CurrentThread.CurrentCulture = ci;
    Thread.CurrentThread.CurrentUICulture = ci;

    Console.WriteLine("CurrentCulture set: " + ci.Name);

Forms (Android and iOS) step by step. First we will create a resource file for default language, in this demo we will use English as Step 4 - Right click on resx file and change the Custom Tool option to public interface ILocalize { CultureInfo GetCurrentCultureInfo (); void SetLocale (CultureInfo ci); } Text is localized in Xamarin.Forms using the generated AppResources class. This class is named based on the default resource file name. Since the sample project resource file is named AppResources.cs, Visual Studio generates a matching class called AppResources. Static properties are generated in the AppResources class for each row in the

Now, change the MainPage design and bind it with MainPageViewModel.cs. The last step is adding the SettingsPage and setting a design that  Xamarin.Forms cross-platform localization using RESX files. Xamarin.iOS native platform localization. Xamarin.Android native platform localization. i18n and L10n. Internationalization is the process of making your code capable of displaying different languages and adapting its display for different locales (such as number and date formatting).

This will query the language set in the device using platform specific code public interface ILocalize { CultureInfo GetCurrentCultureInfo(); void "​platformCultureString"); // in C# 6 use NameOf(platformCultureString) Replace(​"_", "-"); // . Refer to the following code to implement the interface in Android renderer project. Today, I am going to create localization in a Xamarin.Forms app. Whenever I create a Xamarin.Forms app, I want to change the current language and that time, I get stuck in the app. After doing some research, I have got a solution to the problem. So, in this blog, I am going to implement the localization in the Xamarin.forms app.

Most apps from enterprise level to the very basic level, localization is very Loading the resurce files containing culture info and set culture to Setting the language accordin to Language // Set culture by changing sLangCode Thread. using System; using Android. PreviousDelegates in C#, simplified. Gets or sets the CultureInfo object that represents the culture used by the current thread. An object that represents the culture used by the current thread. The property is set to null. The following example demonstrates how to change the CurrentCulture and CurrentUICulture of the current thread. using namespace System; using namespace System

  • additionnal info: in debug mode the cultureinfo is FR but the text of the submit button is still in english. Do I Need to refresh the UI or reload my layout? im not sure...
  • not working... here are my attempts... my goal is to find a way to change the Locale and then as per your answer use the UpdateConfiguration...
  • Im still waiting. Please tell me how I can using C#/Xamarin change the LOCALE. Cause your first line doesnt compile or work. If its not possible for you to give me an answer just tell me. In the meantime ill take a chance with google.
  • I'm sorry, I used to develop that app with a virtual machine but I don't have it anymore. I'm using TFS to look up... We have this code in ActivityBase ` private void SetCurrentCulture() { Resources.Configuration.Locale = new Locale(Thread.CurrentThread.CurrentCulture.Name.ToLower()); Resources.UpdateConfiguration(Resources.Configuration, Resources.DisplayMetrics); }`