Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
How to get current device language if it's been changed after app start?

When you start the app there are a lot of ways to get current device language:

  • CultureInfo.CurrentCulture
  • CultureInfo.CurrentUICulture
  • CultureInfo.DefaultThreadCurrentCulture
  • CultureInfo.DefaultThreadCurrentUICulture
  • Thread.CurrentThread.CurrentCulture
  • Thread.CurrentThread.CurrentCulture

But if I change device language while app is running, none of those values will be updated.

Is there a universal way to get current device language, or do I need to write code for each platform independently?

  • Android: CultureInfo.GetCultureInfo(Locale.Default.ToString().Replace('_', '-'))
  • iOS: CultureInfo.GetCultureInfo(NSLocale.CurrentLocale.LocaleIdentifier.Replace('_', '-'));
  • UWP: CultureInfo.GetCultureInfo(GlobalizationPreferences.Languages[0].ToString())
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Each platform should provide a notification whenever the user changes the device's location or language. For example, iOS sends out a NSCurrentLocaleDidChangeNotification that includes a language property.

You'll need to register for and observe the platform notifications using Xamarin.Forms local notifications procedure, which notes (bolding and italics added):

Each platform handles the creation, display, and consumption of local notifications differently. This article explains how to create a cross-platform abstraction to send, schedule, and receive local notifications with Xamarin.Forms.

  • Create a cross-platform interface

  • Consume the interface in Xamarin Forms

  • Create and handle an Android interface implementation

  • Create and handle an iOS interface implementation

There are a number of tutorials on how to do this. Search on xamarin forms local notification consume tutorial to find some. Note the term local. You're not wanting push notifications - that's something else.

To perform this task more simply, you might be able to use a plugin, such as edsnider/localnotificationsplugin on GitHub. You might find more by replacing the terms consume tutorial with plugin in your search.

Clarification:

  • local notifications occur intra-device, ie, the device or apps send notifications internally to be consumed by apps on the device.
  • push notifications occur when a request is made to an external service, such as Azure. That service would then broadcast a corresponding notification to the appropriate device(s).
over 4 years ago · Santiago Trujillo Denunciar

0

Please try

Java.Util.Locale currentLanguage = this.Resources.Configuration.Locales.Get (0);

I am using this call in Xamarin Android and it works fine for me. "this" is in class Android.App.Activity.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda