android - Run function depending on selected phone language -


is possible run function depending on selected phone language?

i have 3 supported languages. have 3 different functions want run.

thanks

yes, it's possible that.

first, system language using following snippet:

locale.getdefault().getdisplaylanguage(); 

you'll string result, "en", "ru", "pt". , can use if statement call functions accordingly, or suggested on comments, can create generic function , call snippet inside of it.

something like:

void myfunction() {     string mylocale = locale.getdefault().getdisplaylanguage();      if (mylocale.equals("en")) {         // something.     }     else if (mylocale.equals("ru")) {         // else.     } } 

for more info on locale, please refer docs.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -