locked
NumberFormat.DigitSubstitution being ignored? RRS feed

  • Question

  • User1256974442 posted

    I'm trying to localize an ASP.NET MVC application to arabic but while text is converted and displayed correctly, digits remain as used in english.

    Specifically


    <%= DateTime.Now.ToString("dddd, MMMM dd, yyyy hh:mm:ss tt") %>

    outputs

    الاربعاء, مايو 19, 2010 03:22:01 ص

    which means that culture change is being acknowledged but digits remain the same.


    After much researching I've set the DigitSubsitiution enum which some say should(?) (or has?) solved the problem......


    NumberFormat.DigitSubstitution = DigitShapes.NativeNational;

    for both CurrentCulture and CurrentUICulture.

    Debugging shows the value is set correctly in the controller and breaking at the server tags of the Master page or the aspx page, also shows NativeNational value. The windows culture is en-US and the "Standard Digits" in the regional & language options is your usual "123.." but that shouldn't make any difference if I've programmatically set the thread's culture to arabic (for testing) and anyway the text is being localized... and just to be sure I've changed the windows culture and "Standards Digits" and "Digit Substitution" of the Regional & Language opts. and still no change (on Firefox that is, IE just seems to substitute the digits to the same setting as the "standard digits" R&L opts regardless of everything else).


    Is this some kind of massive bug where the Digitsubstitution is just being ignored Or am I missing something here?

    BTW .NET Framework 3.5 and MVC 2 RTM

    Tuesday, May 18, 2010 9:42 PM

Answers

  • User-25924017 posted

    You can try reporting it to http://connect.microsoft.com/

    but I would suggest wait here some time for asp.net Guru's answers. May be they know.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 19, 2010 1:50 PM

All replies

  • User-25924017 posted

    May be useUserOverride is playing some role here: http://msdn.microsoft.com/en-us/library/26xkefd5(v=VS.100).aspx

    when creating culture info.

    The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture.

    If the specified culture identifier matches the culture identifier of the current Windows culture, this constructor creates a CultureInfo that uses those overrides, including user settings for the properties of the DateTimeFormatInfo instance returned by the DateTimeFormatproperty, and the properties of the NumberFormatInfo instance returned by the NumberFormat property. If the user settings are incompatible with the culture associated with the CultureInfo (for example, if the selected calendar is not one of the OptionalCalendars) the results of the methods and the values of the properties are undefined.

    If the specified culture identifier does not match the identifier of the current Windows culture, this constructor creates a CultureInfo that uses the default values for the specified culture.

    The UseUserOverride property is always set to true.

    For example, suppose that Arabic (Saudi Arabia) is the current Windows culture and the user has changed the calendar from Hijri to Gregorian.

    For cultures that use the euro, the .NET Framework and Windows XP set the default currency as euro. However, older versions of Windows do not. Therefore, if the user of an older version of Windows has not changed the currency setting through the regional and language options portion of Control Panel, the currency might be incorrect. To use the .NET Framework default setting for the currency, the application should use a CultureInfo constructor overload that accepts a useUserOverride parameter and set it to false.

    Wednesday, May 19, 2010 12:25 PM
  • User1256974442 posted

    Hey SSA,

    Yeah I thought the UseUserOverride might have something to do with it too but unfortunately it didn't change anything... the UseUserOverride can be set in the constructor of a new CultureInfo class as so:

    CultureInfo bla = new CultureInfo("ar-SA", false);

    nothing worked.

    I think the simple conclusion is there's no built-in way to output local digit shapes. I'd have to manually convert the numbers. I've even checked several Arabic version websites (CNN and BBC).. all display digits as used in English!

    Shouldn't this be considered a bug in the framework or something? What's the proper channel to report this and get a confirmation?

    Wednesday, May 19, 2010 12:45 PM
  • User-25924017 posted

    You can try reporting it to http://connect.microsoft.com/

    but I would suggest wait here some time for asp.net Guru's answers. May be they know.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 19, 2010 1:50 PM
  • User1256974442 posted

    Yes that's a good idea thanks for the link though.

    Wednesday, May 19, 2010 5:31 PM
  • User1256974442 posted

    I'm wondering if anyone's every tried this and managed to get it work without resorting to manual replacement of characters? Anyone?


    Wednesday, May 26, 2010 7:25 PM
  • User-319574463 posted

    You can try reporting it to http://connect.microsoft.com/

    If the problem is reproducible, report it at https://connect.microsoft.com/dashboard/?wa=wsignin1.0

    You will need to be very precise in your report not just in the steps to reproduce but in specifying your environment as well - e.g. Version of Framework, Operating System and localisation settings

    Please post a link here to your report on MSConnect, so that others with the same problem may confirm your report.


    Saturday, June 26, 2010 4:25 AM