qooxdoo / qooxdoo

qooxdoo - Universal JavaScript Framework
http://qooxdoo.org
Other
764 stars 259 forks source link

Wrong narrow stand-alone locale #10664

Open goldim opened 2 months ago

goldim commented 2 months ago

During implementing cldr functionality via Intl API. I am stucked with some tests of method getDayNames. What we have:

var narrowDays = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
this.assertJsonEquals(
  narrowDays,
  Date.getDayNames("narrow", useLocale, "stand-alone").map(function (v) {
    return v + "";
  })
);

But if we have a look at cldr data we will see that for narrow both as "format" and "stand-alone" case there are words with only one letter. If it is a bug then how does it have to be handled? Fixing tests will lead to error in current implementation (cldr) or it could be changed only with new impl via Intl API?

johnspackman commented 2 months ago

So CLDR has a single-character day name, but Intl only goes as short as two character day names?

Perhaps we should define a set of overrides for specific locales, and then maintain that (hopefully very small) list ourselves?

goldim commented 2 months ago

@johnspackman What it is in my link:

<dayContext type="stand-alone">
<dayWidth type="abbreviated">
    <day type="sun">So</day>
    <day type="mon">Mo</day>
    <day type="tue">Di</day>
    <day type="wed">Mi</day>
    <day type="thu">Do</day>
    <day type="fri">Fr</day>
    <day type="sat">Sa</day>
</dayWidth>
<dayWidth type="narrow">
    <day type="sun">S</day>
    <day type="mon">M</day>
    <day type="tue">D</day>
    <day type="wed">M</day>
    <day type="thu">D</day>
    <day type="fri">F</day>
    <day type="sat">S</day>
</dayWidth>
</dayContext>

You may see that for narrow stand-alone case one-letter words but in the test checking against 2. Is the test wrong?

Btw I have other rep and there are for de_DE listed all cases ("narrow", "wide", "abbreviated", "short"). But in this one narrow stand-alone version has also consist of one letter.

Perhaps we should define a set of overrides for specific locales, and then maintain that (hopefully very small) list ourselves?

No, we shouldn't. Intl has everything but I can stumble on some date/time format I can not reimplement, maybe.

hkollmann commented 2 months ago

Why is the test working in the current version?

goldim commented 2 months ago

@hkollmann bc it was implemented with an error? Look at the source file:

 cldr["cldr_day_stand-alone_narrow_fri"] = find(
                row.dayWidth[0].day,
                "type",
                "fri",
                getText
);

We take the first element (index 0) but it is abbreviated.

hkollmann commented 2 months ago

Wrong test hides wrong implementation. Should be fixed both

goldim commented 2 months ago

@hkollmann but I think of just fixing it in new implementation if I finish it.