Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by VivienAdnot · Apr 06, 2016 at 09:14 AM · wwwwwwformlanguagehttpwebrequest

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 !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Eldoir · Mar 07, 2018 at 12:16 PM

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".

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by streeter12 · Feb 16, 2017 at 12:10 PM

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));
    }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Raitoning · Jun 11, 2016 at 04:53 PM

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 :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Stals · Sep 02, 2016 at 12:38 PM

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)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Michael-Ryan · Jul 28, 2020 at 11:12 PM

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: https://stackoverflow.com/questions/63125198/how-to-convert-datetime-to-string-using-region-short-date/63125506#63125506

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

62 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The network connection was lost 1 Answer

UnityWebRequest returns an empty string 1 Answer

How to get image from server folder through its reference in mysql database 0 Answers

Having Trouble with Post to Server 0 Answers

www request Error unity 2018 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges