ios - How to get correct value for CurrentCulture? -


on iphone, user can choose display language , region used formatting.
display language equivalent .net's thread.currentuiculture, i.e. language of ui.
formatting region equivalent .net's thread.currentculture, i.e culture settings used formatting numbers, dates etc.

assume following settings:
language: english
region: germany

in ios6, nslocale.currentlocale return "de_de", transform cultureinfo object.
however, since then, things have changed.
example, on ios8, "en_de" invalid value cultureinfo.

so, preferred way make sure xamarin.ios application takes account settings chosen user, i.e. how correct value thread.currentculture?

i think answered own question:

changing region germany doesn't change formatting long user didn't explicitly switch off "automatic" in regions advanced settings , changed language german, too. in case, formatting different ui language.

based on that, using code now:

private static cultureinfo getformattinglanguage() {     try     {         return cultureinfo.getcultureinfo(             nslocale.currentlocale.localeidentifier.replace('_', '-'));     }     catch (culturenotfoundexception)     {         return cultureinfo.getcultureinfo(nslocale.currentlocale.languagecode);     } } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -