C# CurrentCulture always return "en-US"

Hello everybody,

I’ve a problem when trying to retrieve the current langage on which the game runs. When I call CurrentCulture.CurrentUICulture, Unity always gives me back “en-us”. However, my Windows is not English but French, and if I run the very same code on a new separate project from Unity, it returns me “fr-FR”, which is right. I really need to retrieve the current language because I’m localizating my game and I need to adapt the display of the date and time to the local standard where the player is living.

This is the code I’ve put in the separate project:

static void Main(string[] args)
{
     CultureInfo Culture;
     Culture = CultureInfo.CurrentUICulture;
     Console.Write("Current culture: " + Culture);
     Console.Read();
}

Which returns me the correct current culture:
2674287--188796--WindowsCulture.png

But on Unity, the nearly same code doesn’t return the same thing:

void Start(){

        Culture = CultureInfo.CurrentUICulture;
        Debug.Log("Current culture: " + Culture);
}

Which always return “en-US”:
2674287--188798--UnityCulture.png

I saw someone else having the very same problem but nobody answered him already, this is why I create a thread for this issue.

Link of the other thread: Why current culture is always en-US and what is the alternative ? - Questions & Answers - Unity Discussions

If someone knows why, or if it’s related to the Unity Engine, please let us know :slight_smile: Thanks for reading :slight_smile:

What platform are you on? If you’re on Universal Windows Platform for Windows 10 I use this to get the current languageWindows.System.UserProfile.GlobalizationPreferences.Languages[0]

I am on Windows 10, but I already had this problem on Windows 7 and Windows 8.1.

I don’t know what “Universal Windows Platform for Windows 10” is, a kind of a special development platform for all Windows 10 products ?

It may be that your code or Unity sets this property somewhere. Have you tried using CultureInfo.InstalledUICulture instead? That should return the cultureinfo installed with the Os.

The two codes are the same. I’ve already tried to use InstalledUICulture too, and it show the same result. I’m not the only one having this issue, as I’ve put a link to a question from someone else that also have this issue. Maybe Unity runs on it own version of the .net, that would explain why it always return “en-US”.

Unity does run on it’s own version of .Net - an old (2009) version of Mono.

Yeah, it’s bad.

Google is your friend, by the way. This was the first search result.

Edit: more search results.

This may not be required, but it cant hurt to mention

Some people don’t use Google, and I used the search toolbar at the top of the forum, and I didn’t found something usefull.

If I knew before that those functions were broken, I would have checked the Script References before.

Anyway, thanks for your answers.

SystemLanguage doesn’t fit very well for what I’m doing, because I’d like to adapt the display of the date and time to the locale standard where the player live. So I’ll have to lock everybody with the English way of writing the date/time, unless there is another way to retrieve the player’s OS language.