Practical Uses for Replacement Cultures/Locales

by Michael S. Kaplan, published on 2006/03/20 03:01 -05:00, original URI:

In the past, I have talked a lot about genitive month names.

And I have talked a few times about custom cultures.

And as Shawn mentioned last month, he and I were talking about replacement cultures and situations where they could come in handy.

Now, in the spirit of acting like I know something linguistic, I will juxtapose these three concepts and create a scenario that may or may not actually exist, to try and show another practical use of these features. :-)

For our current discussion, we are going to look at Armenian, and the Armenian - Armenia culture, represented by LCID 0x042b or the hy-AM culture name.

Armenian is one of those languages that has a suffix for the genitive form, usually ի (U+056b, a.k.a. ARMENIAN SMALL LETTER INI). Look, however, in running that code I posted before:

E:\test>genitive.exe hy-AM
Հունվար        Հունվար       1 Հունվար, 2006
Փետրվար       Փետրվար      1 Փետրվար, 2006
Մարտ         Մարտ         1 Մարտ, 2006
Ապրիլ         Ապրիլ         1 Ապրիլ, 2006
Մայիս         Մայիս         1 Մայիս, 2006
Հունիս         Հունիս         1 Հունիս, 2006
Հուլիս         Հուլիս          1 Հուլիս, 2006
Օգոստոս       Օգոստոս       1 Օգոստոս, 2006
Սեպտեմբեր     Սեպտեմբեր    1 Սեպտեմբեր, 2006
Հոկտեմբեր      Հոկտեմբեր     1 Հոկտեմբեր, 2006
Նոյեմբեր       Նոյեմբեր       1 Նոյեմբեր, 2006
Դեկտեմբեր     Դեկտեմբեր     1 Դեկտեմբեր, 2006

As you can see, that suffix is not there -- the genitive month names are the same as the non-genitive ones.

But what if there were an expectation that they be there in more some cases? Like perhaps in more formal situations, for example. In that case, not having them might not be a mistake, but having them there might be the right thing to do in some situations?

Microsoft would choose one way, but what if a person pretty consistently needed the other?

Ah, then thank goodness for custom cultures, huh? :-)

The code to create that custom culture (assuming you were not running the beta of the Microsoft Locale Builder Tool!) could look something like this:

CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder("hy-AM", CultureAndRegionModifiers.Replacement);

carib.LoadDataFromCultureInfo(new CultureInfo("hy-AM"));
carib.LoadDataFromRegionInfo(new RegionInfo("hy-AM"));

string[] rgMgn = carib.GregorianDateTimeFormat.MonthGenitiveNames;
string[] rgAmgn = carib.GregorianDateTimeFormat.AbbreviatedMonthGenitiveNames;

carib.GregorianDateTimeFormat.MonthGenitiveNames =
  new string[] {rgMgn[0] + "ի",
                rgMgn[1] + "ի",
                rgMgn[2] + "ի",
                rgMgn[3] + "ի",
                rgMgn[4] + "ի",
                rgMgn[5] + "ի",
                rgMgn[6] + "ի",
                rgMgn[7] + "ի",
                rgMgn[8] + "ի",
                rgMgn[9] + "ի",
                rgMgn[10] + "ի",
                rgMgn[11] + "ի",

carib.GregorianDateTimeFormat.AbbreviatedMonthGenitiveNames =
  new string[] {rgAmgn[0] + "ի",
                rgAmgn[1] + "ի",
                rgAmgn[2] + "ի",
                rgAmgn[3] + "ի",
                rgAmgn[4] + "ի",
                rgAmgn[5] + "ի",
                rgAmgn[6] + "ի",
                rgAmgn[7] + "ի",
                rgAmgn[8] + "ի",
                rgAmgn[9] + "ի",
                rgAmgn[10] + "ի",
                rgAmgn[11] + "ի",


Now after that code has been run, there is a replacement culture, and that EXE has a slightly different set of answers:

E:\test>genitive.exe hy-AM
Հունվար       Հունվարի       1 Հունվարի, 2006
Փետրվար      Փետրվարի      1 Փետրվարի, 2006
Մարտ         Մարտի        1 Մարտի, 2006
Ապրիլ         Ապրիլի        1 Ապրիլի, 2006
Մայիս         Մայիսի        1 Մայիսի, 2006
Հունիս         Հունիսի        1 Հունիսի, 2006
Հուլիս         Հուլիսի         1 Հուլիսի, 2006
Օգոստոս       Օգոստոսի      1 Օգոստոսի, 2006
Սեպտեմբեր    Սեպտեմբերի    1 Սեպտեմբերի, 2006
Հոկտեմբեր     Հոկտեմբերի     1 Հոկտեմբերի, 2006
Նոյեմբեր       Նոյեմբերի      1 Նոյեմբերի, 2006
Դեկտեմբեր     Դեկտեմբերի    1 Դեկտեմբերի, 2006

So, if such a change were, in fact, important to have happen in the .NET Framework (or in Vista!) it would happen.

(As an aside, web searches on those month names with and without the genitive suffix get some hits that appear to be date strings -- both types of strings are in fact seen. So maybe the issue is not as theoretical as I suggested earlier in this post!)


This post brought to you by ի (U+056b, a.k.a. ARMENIAN SMALL LETTER INI)

# Nick Lamb on 20 Mar 2006 3:56 AM:

My understanding is that Armenian is effectively split into several mutually incomprehensible dialects. Without first-hand experience it's always hard to judge how serious this is, eg. some people taught Received Pronunciation regard Scots, especially Glaswegian as incomprehensible while others find it no harder to understand than the dialect of the West Country. You might find that the use of the genitive form differs between dialects. The locale data installed on the computer where I'm writing this does include the U+056B suffix out of the box for what it's worth.

# Michael S. Kaplan on 20 Mar 2006 10:18 AM:

Hi Nick,

Ah yes, but given that, this sample is even more immediately, potentially useful. Is it not? :-)

# Nick Lamb on 20 Mar 2006 9:57 PM:

Well, Vista's support sounds a bit more comprehensive. It would be/ will be nice to be able to tell users that they can even fix locale problems on Windows as they can on other systems.

As Raymond Chen is surely never slow to remind people, most code is not .NET code and thus won't benefit from any .NET hacks like this, no matter how clever.

# Michael S. Kaplan on 20 Mar 2006 10:45 PM:

Hi Nick,

Well, since you can update almost everything in any locale, and since you can even create your own, I guess you can consider it all pretty damn configurable.

Beyond that, the Microsoft Locale Builder Tool (which is in Beta now) will run on Vista and will allow you to do all of this without writing any code at all. Perhaps this might help the cincept graduate from hack in your mind, compared to the tools used on other platforms to do the same thing?


# Nick Lamb on 21 Mar 2006 5:34 AM:

“I guess you can consider it all pretty damn configurable.”

This only becomes true for regular users when they get Vista. I guess from inside Microsoft Vista already feels like ancient history? Until they have Vista, users are stuck with "Here's a partial solution that only affects .NET applications", hence my Raymond Chen reference.

If there's a criticism here it's just that I think custom locales (and all that they entail) were overdue, which makes it all the more important. After all, a lot of other things I think are overdue didn't even make it into Vista.

Anyway, to re-affirm, yes, MLBT + Vista is good stuff. I will be interested to see what MLBT does to help people understand and create collation rules.

# Michael S. Kaplan on 21 Mar 2006 6:24 AM:

Sigh, not what I said, Nick. But this is not the sort of feature that can be is easily weaved into existing versions. It does not mean I think Vista is old hat, but it does mean I think its where we have provided and will be providing some new and groundbreaking functionality for Windows.

To answer the new point, custom collation is not a part of the Microsoft Locale Builder Tool, only the ability to choose among existing collations is there (this is what is available in custom cultures, too).

This is a new blog topic, obviously (so I don't want to commandeer this one for it, if you know what I mean!), but understanding and creating collation rules is the sort of thing that would take a lot more than currently exists on *any* platform (and I do not include UCA tailorings as a "solution", due to the astronomically high linguistic and technical requirements that they bring to the mix).

referenced by

2008/05/14 Windows is too busy being consistent with the user to be consistent with itself!

2007/08/04 A re-genitive post

2006/10/09 Where the hell did Replacement Locales come from?

2006/09/06 IsSortable() == false? Well, sometimes it may be lying....

2006/05/18 Where are the other Tamils?

2006/04/08 It may not always end with ի

go to newer or older post, or back to index or month or day