Bug 15875 - CultureInfo.CurrentCulture needs more intelligent fallback
Summary: CultureInfo.CurrentCulture needs more intelligent fallback
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
: 16417 ()
Depends on:
Blocks:
 
Reported: 2013-11-01 09:43 UTC by Jonathan Pryor
Modified: 2013-12-04 10:51 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Pryor 2013-11-01 09:43:54 UTC
On Unixy platforms (Linux, Android), CultureInfo.CurrentCulture can be set based on the $LANG and/or $LC_ALL environment variables:

  $ cat > loc.cs <<EOF
  using System;
  using System.Globalization;

  class Test {
    public static void Main (string[] args)
    {
      var cur = CultureInfo.CurrentCulture;
      Console.WriteLine ("Current Culture: {0} {1}",
          cur.IetfLanguageTag, cur == CultureInfo.InvariantCulture);
    }
  }
EOF
  $ mcs loc.cs
  $ mono loc.cs
  Current Culture: en-US False

  $ LANG=de-DE mono loc.exe
  Current Culture: de-DE False

(Related: it would be really handy for test purposes if OS X and Windows would likewise check $LANG and $LC_ALL _before_ using locales.c!get_darwin_locale(), as that would allow testing this on OS X...)

The problem is when an "invalid" culture is specified (Bug #15214):

  $ LANG=de-FR mono loc.exe
  Current Culture:  True

What is desired is that $LANG/$LC_ALL detection would involve the fallback detection logic, so that it behaves more like CultureInfo.CreateSpecificCulture(), and thus LANG=de-FR would "fallback" to behaving "as if" LANG=de-DE were specified.
Comment 1 Marek Safar 2013-12-04 10:47:30 UTC
Fixed in master
Comment 2 Marek Safar 2013-12-04 10:51:25 UTC
*** Bug 16417 has been marked as a duplicate of this bug. ***