Search Feedback

260
votes
Started

Fix localization issues with correct CultureInfo.CurrentCulture

Runtime

-

-

System.Globalization.CultureInfo.CurrentCulture seems to always indicate the "en-US" culture, which makes correct parsing and display of dates, currencies, etc. difficult. I believe this is because Unity is using the reference implementation of the Mono CLR, namely https://github.com/mono/mono/blob/master/eglib/src/gmisc-win32.c, in which g_win32_getlocale explicitly returns "en-US".

I just added a reply to this thread -- http://forum.unity3d.com/threads/5452-Getting-user-s-language-preference?p=1076329 -- in which I explain a workaround for the Unity Editor and Windows standalone builds. Unfortunately it doesn't work in the web player because I can't use DllImport to call into kernel32.dll.

Many thanks.

Response avatar

karl_jones

Jan 18, 2018

This should be fixed for some platforms using the .Net 4.6 support. For other platforms we will investigate adding support.

Comments (13)

  1. 6afbab9aa3198d4594dfd360f122e0df?d=mm

    BoaNeo

    Oct 04, 2017 09:18

    @karl_jones: How is this fixed?

    I'm on 2017.1.1p2 and have set the .Net version to 4.6 yet both iOS and OsX still returns US English no matter what the system is set to.

  2. Aa02a6bf34c791e1db3dee66e9b8c833?d=mm

    SevenPointRed

    Jul 12, 2017 09:02

    They are never going to fix this.

  3. 637f649c003331837e3c2428ac40936c?d=mm

    KevinGelking

    Jun 21, 2017 10:51

    I don't think this will ever be fixed, it's been a known issue in Unity for 10 f*ing years. :)

  4. E80b48f67e9d94238805c77d9edd1ba2?d=mm

    mwk888

    Feb 24, 2017 17:42

    I can't believe this is still not fixed in 5.5. Application.SystemLanguage is not a solution for issues like displaying localized time.

    To Unity: if you are postponing this fix because of concerns that setting CultureInfo automatically will break backwards compatibility, how about you just add a new method Application.systemLocale which returns the Android/iOS locale string. Then we can workaround the problem by explicitly setting CultureInfo and legacy apps would not be affected.

  5. E742a36229aa88eaf1d70181128941d0?d=mm

    khan-amil

    Feb 23, 2017 12:57

    Still true on 5.5.1 :/

    At least there's Application.SystemLanguage

  6. Ad9dc2efe867a0fe541257f556e51e8f?d=mm

    radiatoryang

    May 24, 2016 16:58

  7. Ad9dc2efe867a0fe541257f556e51e8f?d=mm

    radiatoryang

    May 24, 2016 16:58

    this has been a bug, literally, since 2007

  8. Cb25b29ad3258cb846b77d605488a2e2?d=mm

    benjamin_playhybrid

    Apr 22, 2016 14:15

    It's insane that all that's available to us in Unity is the name of the language, without any locale information -- that's not enough to figure out what to display! We can't even differentiate between US and British English...

  9. 4d372b7533d7cdd59028a41bb0b2bf9b?d=mm

    hanger

    Nov 12, 2015 18:45

    Note that Mono actually does contain quite a few locales built in, and I've had some success grabbing locale information from Android/iOS/Windows and iterating through locales to find the closest match. (On Windows, use LCID, on other platforms, use language + country code. Avoid neutral locales.)

    Newer versions of Mono contain quite a lot more built-in locales, and those locales seem pretty compatible with current mono. I'd love for you to backport them. (I don't think mono has any means to grab real locale data from the machine itself.) Newer mono does have some intelligent ways of guessing the correct locale.

    You could also figure out how to grab the actual locale data from each platform, because nowadays users have overrides that they're particular about, but that seems like a lot more work than necessary for a game.

    There is the issue that most Unity code has been written assuming CultureInfo.CurrentCulture is CultureInfo.InvariantCulture. Imagine that screwing with a JSON emitter that ToString()s a float and suddenly starts using a comma on European phones. There's also CultureInfo.CurrentUICulture, but in the .NET world, that's only used for resource lookups. See http://www.siao2.com/2007/01/10/1442340.aspx

    So you could break compatibility, you could use CurrentUICulture wrong, or you could just have an Application.CurrentCulture or something. Frankly, most of the time I want InvariantCulture anyway for logging, etc, in Unity. I'd suggest the Application.CurrentCulture route.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(10516)

2D

(274)

Ads

(52)

AI & Navigation

(78)

Analytics

(125)

Animation

(389)

Asset Store

(332)

Asset Store Publisher

(10)

Assets

(534)

Audio

(176)

Cloud Build

(139)

Collaborate

(57)

Docs & Tutorials

(237)

Editor

(2452)

Everyplay

(14)

Game Performance Reporting

(15)

General

(950)

Graphics

(861)

GUI

(422)

Input

(165)

Licensing

(88)

Networking

(185)

Physics

(380)

Platforms

(438)

Profiling & Optimization

(81)

Runtime

(180)

Scripting

(1147)

Terrain

(168)

WebGL

(141)