Why current culture is always en-US and what is the alternative ?

Hello everybody,

I’m using the WWW class to perform a https request and I don’t specify accept-language in the headers.

My problem is: the server receives always en-US as Accept-Language in the headers of the request, regardless of the real country of the user.

I want to retrieve the currentCulture of the user and pass it to the WWW class.

But I don’t know how to retrieve it ! I read in another threads that System.Globalization.CultureInfo.CurrentCulture and System.Threading.Thread.CurrentThread.CurrentCulture are set to “en-US” by default.
Do you know another way to retrieve the culture code ?

PS: I would like to avoid using a geolocation plugin as much as I can because our server relies on currentculture instead of ips to detect the location of the user. It would represent a heavy update to filter by ip rather than culture code.

Thank you for your help guys !

You can use this function to get CultureInfo from SystemLanguage enum values.

   private static CultureInfo GetCultureDefualt(SystemLanguage language)
            return CultureInfo.GetCultures(CultureTypes.AllCultures).
                FirstOrDefault(x => x.EnglishName == Enum.GetName(language.GetType(), language));

Hello there,
I found the answer of @streeter12 very interesting but I got an exception when I tried to use the CultureInfo with date formatting.
After nearly an hour of struggle and research in obscure documentation, I finally managed to create a broader method, that works with formatting. Here it is!

public static CultureInfo GetCurrentCultureInfo()
    SystemLanguage currentLanguage = Application.systemLanguage;
    CultureInfo correspondingCultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(x => x.EnglishName.Equals(currentLanguage.ToString()));
    return CultureInfo.CreateSpecificCulture(correspondingCultureInfo.TwoLetterISOLanguageName);

Don’t forget to add using System.Linq and using System.Globalization on top of your script.
I’m now able to write something like this :

Debug.Log(System.DateTime.Now.ToString("dd MMMM", GetCurrentCultureInfo()));

And as I’m french, it displays as “07 mars”.

Hello @VivienAdnot,

I’ve got the exact same problem as you. I really need to retrieve the current culture of the player’s system to adapt the display of the date and time to the player’s local standards. As no one answered you, I’ve created a thread on the forum to find some help. I’ve also put a link to this question in the thread. I hope someone will find a solution to this.

Link to the thread: http://forum.unity3d.com/threads/c-currentculture-always-return-en-us.410482/

Thanks for reading :slight_smile:

As I can see this now, there is just no good solution (aside from making a plugin that supports all platforms but it surely feels like Unity should do it in-engine), but we can vote for this task would be resolved https://feedback.unity3d.com/suggestions/fix-localization-issues-with-cor (all of my 10 votes goes towards it)

I realize this is an old post, but I found a work around to getting the actual values that the user set in their operating system.

Details are posted here: c# - How to convert DateTime to string using Region Short Date - Stack Overflow