-
Notifications
You must be signed in to change notification settings - Fork 24
[future] capitalization context #11
Comments
There are a bunch more contexts linked from there. How did you arrive at this more minimal set? |
I don't remember, but it may be that I was just going for the minimal set that provides the default (standalone) and in-sentence options. I don't see a reason not to add others, but for l10n purposes those three would probably be the most important ones. |
We don't support this in DateTimeFormat. And I think |
I hope you're not thinking of using |
I'm thinking of using parts, plus a little bit of data or function on the client side to decide when to capitalize, and apply a css to an span around the parts. |
@caridy How would you do the actual capitalization? |
This could be a poor man implementation of capitalization for weekdays: new Intl.DateTimeFormat('en', { weekday: 'short' }).formatToParts(Date.now()).reduce((result, part) => {
if (part.type === 'weekday') {
const c = shouldLocaleWeekDayBeCapitalizedForThisCase(); // CLDR based implementation
result += `<span class="${c ? 'upper' : 'lower' }">${[art.value}</span>`;
}
return result;
}, '') Again, my point is that some of this kind of stuff can be done in user-land today with parts and a little bit of CLDR data. |
@caridy What's the CSS that backs the upper/lower classes? That's the part that I'm getting at that worries me more. |
Oh, that's just text transformation: .upper {
text-transform: capitalize;
}
.lower {
text-transform: lowercase;
} |
Yeah,
The typographical letter unit is defined as:
For one, Firefox seems to recognize the Dutch IJ digraph as a single typographical character unit when the text has that language declared, whereas Chrome seems to treat it as two, leading to a linguistically incorrect output. (See examples on the MDN article). Until the CSS spec is clarified or a new, more linguistically accurate feature is added, I think we should avoid recommending anyone to use |
The way I see it, So my advice would be to use If you find faults in the way CSS invokes unicode, then this is certainly something we'd want to fix in CSS, but CSS absolutely wants to defer to unicode the language specific questions on this topic. Just my 2 cents, possibly missing the point entirely since I was sort of summoned without knowing much of the context. |
Eh, OK, FWIW there's a Blink bug about the IJ thing. |
I don't think we can expect formatToParts + CSS to replace this feature for localization purposes. Firstly, because CSS is meant for styling, while what we're trying to format is content. I don't think you can argue that taking "You should leave In 5 minutes" should be formatted by using Secondly, because of the performance reasons. Thirdly (not verified), my intuiting tells me that not in all languages the sentence start/middle/end differs just by capitalization. |
I'm reviewing the Firefox patch and independently raised this issue -- good to see people on this. I'm leery of not having context be part of the 1.0 API. It seems a small enough adjustment (implementation-wise and spec-wise) that I'd just do it now. Context information doesn't introduce cross-cutting complexity concerns that clearly would motivate deferring. And failing to specify context now, leaves room for surprising authors and enabling cross-implementation disagreement. However, I'm fine with not having context control in 1.0 if the specification requires a particular context be used, that would be the default in a customizable future. " |
OK, if this is the single most useful context, I don't have any real objection to adding it for 1.0. Anyone else have a source of hesitation? |
I believe that if we don't allow for context selection, the standalone is the only one we can operate with so I agree with Jeff about adding the note. |
Relative time format may be useful within localization contexts but in order for that to work, we'd need to follow ICU and expose ability to capitalize the formatted string.
ICU exposes
UDisplayContext
[0] which in this case would take one of the three valuesstandalone
,sentence-start
orsentence-middle
. Example:I don't think we should do this for the first revision, but wanted to file an issue already to put it in peoples radar when talking about API.
[0] http://www.icu-project.org/apiref/icu4c/udisplaycontext_8h.html#ac80aa1aceff6c7ad2e9f983a19d8d868
The text was updated successfully, but these errors were encountered: