[Mono-dev] set culture uses serialization?

Robert Jordan robertj at gmx.net
Sat Jan 5 19:11:14 EST 2008


Steve,

I think resorting to manual optimization won't help very
much, because it's hard to foresee whether the BCL code
you are calling is not accessing CurrentThread.CultureInfo
at some point. A simple call of this getter would kill your
efforts.

Since the current handling of CurrentThread.CultureInfo
isn't quite perfect (changes of CurrentThread.CultureInfo's
object state isn't reflected back into another app domains,
like on MS.NET), I wonder why we don't use a more efficient way:
cache the LCID instead of the full blown binary representation
of the CultureInfo.

Robert

Steve Bjorg wrote:
> Thanks for clarifying.  So, what is the recommended practice for  
> concurrently multi-lingual applications?  Do I need to track down  
> each use of culture dependent string operations and pass in the  
> wanted CultureInfo explcitly?  Or is the overhead of setting the  
> CultureInfo low enough that there is no reason to worry?
> 
> - Steve
> 
> ---------------------------------
> Steve G. Bjorg
> 
> MindTouch
> 555 W. Beech St.
> Suite 501
> San Diego, CA 92101
> 
> 619.795.8459x1106 office
> 619.795.3948 fax
> 425.891.5913 mobile
> 
> 
> 
> On Jan 5, 2008, at 11:32 AM, Robert Jordan wrote:
> 
>> Steve,
>>
>> this is by design.
>>
>> The GC error you encountered during the deserialization of CultureInfo
>> was fixed in 1.2.6.
>>
>> Robert
>>
>> Steve Bjorg wrote:
>>> I spoke too soon.  I tested on an old version mistakenly.  1.2.6 has
>>> now Korean and Konkani.  Sweet!  I updated our languages page.
>>>
>>> That only leaves the issue with using serialization when setting
>>> CurrentCulture.  Is that by design or a bug?  If by design, what is
>>> the recommended pattern for supporting difference cultures on
>>> different threads?
>>>
>>> - Steve
>>>
>>> --------------
>>> Steve G. Bjorg
>>> http://wiki.mindtouch.com
>>> http://wiki.opengarden.org
>>>
>>>
>>> On Jan 5, 2008, at 7:15 AM, Steve Bjorg wrote:
>>>
>>>> Korean culture cannot be instantiated as
>>>> 	new CultureInfo("ko-kr")
>>>> throws an exception stating it's not implemented.
>>>>
>>>> There is work item filed to be update the locale builder:
>>>> https://bugzilla.novell.com/show_bug.cgi?id=324483
>>>>
>>>>
>>>> There are other cultures missing as well.  The following code
>>>> instantiates all 134 cultures lists in the attached file.
>>>>
>>>> using System;
>>>> using System.Globalization;
>>>>
>>>> namespace CultureCheck {
>>>>     class Program {
>>>>         static void Main(string[] args) {
>>>>             if(System.IO.File.Exists("cultures.txt")) {
>>>>                 string[] cultures = System.IO.File.ReadAllLines
>>>> ("cultures.txt");
>>>>                 int failed = 0;
>>>>                 int succeeded = 0;
>>>>                 foreach(string culture in cultures) {
>>>>                     try {
>>>>                         CultureInfo info = new CultureInfo
>>>> (culture.Trim());
>>>>                         string now = DateTime.UtcNow.ToString
>>>> (info.DateTimeFormat);
>>>>                         ++succeeded;
>>>>                     } catch {
>>>>                         ++failed;
>>>>                         Console.WriteLine(culture);
>>>>                     }
>>>>                 }
>>>>                 Console.WriteLine("Tested {0} cultures: {1}
>>>> succeeded, {2} failed", succeeded + failed, succeeded, failed);
>>>>             } else {
>>>>                 Console.Error.WriteLine("MISSING FILE:  
>>>> cultures.txt");
>>>>             }
>>>>         }
>>>>     }
>>>> }
>>>>
>>>>
>>>> Only 26 out of 134 cultures fail on mono 1.2.6:
>>>> az-cyrl-az
>>>> az-latn-az
>>>> dv-mv
>>>> en-bz
>>>> en-029
>>>> en-jm
>>>> en-tt
>>>> fr-mc
>>>> ka-ge
>>>> de-li
>>>> kk-kz
>>>> kok-in
>>>> ko-kr
>>>> ky-kg
>>>> ms-bn
>>>> ms-my
>>>> mn-mn
>>>> pa-in
>>>> sa-in
>>>> sr-cyrl-cs
>>>> sr-latn-cs
>>>> syr-sy
>>>> tt-ru
>>>> ur-pk
>>>> uz-cyrl-uz
>>>> uz-latn-uz
>>>>
>>>> List of missing cultures is also available here (highlighted in
>>>> yellow): http://wiki.opengarden.org/Deki_Wiki/Languages
>>>>
>>>> Some of these should be trivial as they are identical to existing
>>>> ones:
>>>> * English (Belize)
>>>> * English (Caribbean)
>>>> * English (Jamaica)
>>>> * English (Trinidad and Tobago)
>>>> * French (Monaco)
>>>> * German (Liechtenstein)
>>>>
>>>> Others are likely more complicated.  Of those, a high-priority
>>>> culture is Korean.
>>>>
>>>>
>>>> - Steve
>>>>
>>>> --------------
>>>> Steve G. Bjorg
>>>> http://wiki.mindtouch.com
>>>> http://wiki.opengarden.org
>>>>
>>>>
>>>> On Jan 4, 2008, at 10:47 PM, Miguel de Icaza wrote:
>>>>
>>>>>> This issue and the fact that Korean isn't supported for  
>>>>>> CultureInfo
>>>>>> are blockers for a large customer deployment of ours.  Is there  
>>>>>> any
>>>>>> way these issues can be addressed?  Who is working on CultureInfo?
>>>>> What seems to be the problem with Korean?
>>>>>
>>>>> Please provide a stack trace, a bug report, or a sample program  
>>>>> that
>>>>> fails with Korean.
>>>>>
>>>>> Miguel.
>>>>>
>>>>>
>>>>> <cultures.txt>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>




More information about the Mono-devel-list mailing list