Merging unit skeletons for output - a better way?
Richard Wordingham
richard.wordingham at ntlworld.com
Sun May 17 03:30:33 CDT 2020
On Sat, 16 May 2020 15:26:05 +0800
Kip Cole via CLDR-Users <cldr-users at unicode.org> wrote:
> 1. In order to resolve the skeleton for the denominator “second” I
> take the plural value for “1” (ie always singular form)
> 2. Ignore the placeholder in the denominator so “{0} second” becomes
> “ second”
> 3. String join the three skeletons
> 4. Merge the number value into the placeholder “{0}”
> 5. Replace the double space between “per” and
> “second” that arises because there is a trailing space in the “per”
> skeleton and a leading space in the “ second” skeleton
So, even where the compoundUnit pattern should work, your space
stripping algorithm seems to be wrong. (For example, it should only go
wrong for Russian with feminine denominator units.) The rules for
inserting spaces can be complicated. I don't know of anything more
complicated than Thai, but it may exist.
At step 2, you strip the placeholder and its surrounding spaces. This
makes step 5 redundant.
Step 3 is a substitution, not a concatenation. Perhaps that is what
you mean by 'join' - I couldn't find the code that performs this step.
Not only can denominator unit precede the numerator unit, but a quick
glance at translations indicates that the denominator can occur
multiple times, as though a fairly literal translation were "3
kilometres second by second". (Hawaiian is the example I have in mind.)
I think step 4 should be done before step 3. Does the compound
skeleton inherit the plural rules?
Richard.
More information about the CLDR-Users
mailing list