1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

LibUnicode: Parse number formats into zero/positive/negative patterns

A number formatting pattern in the CLDR contains one or two entries,
delimited by a semi-colon. Previously, LibUnicode was just storing the
entire pattern as one string. This changes the generator to split the
pattern on that delimiter and generate the 3 unique patterns expected by
ECMA-402.

The rules for generating the 3 patterns are as follows:

* If the pattern contains 1 entry, it is the zero pattern. The positive
  pattern is the zero pattern prepended with {plusSign}. The negative
  pattern is the zero pattern prepended with {minusSign}.

* If the pattern contains 2 entries, the first is the zero pattern, and
  the second is the negative pattern. The positive pattern is the zero
  pattern prepended with {plusSign}.
This commit is contained in:
Timothy Flynn 2021-11-10 08:54:45 -05:00 committed by Linus Groh
parent 1244ebcd4f
commit 230b133ee3
2 changed files with 69 additions and 11 deletions

View file

@ -104,7 +104,9 @@ struct NumberFormat {
u8 magnitude { 0 };
Plurality plurality { Plurality::Other };
StringView format {};
StringView zero_format {};
StringView positive_format {};
StringView negative_format {};
};
struct ListPatterns {