Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda