Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

[WIP] Use CLDR data for list separators#45

Open
thewilkybarkid wants to merge 8 commits intolibero:masterfrom
thewilkybarkid:cldr-data
Open

[WIP] Use CLDR data for list separators#45
thewilkybarkid wants to merge 8 commits intolibero:masterfrom
thewilkybarkid:cldr-data

Conversation

@thewilkybarkid
Copy link
Contributor

The result of this initial commit is what we want: locale data coming from CLDR where possible. The JS will need tidying up but works.

Picking out the right data is tricky. Locale codes in CLDR are similar to BCP 47 (used by HTML), but a bit different. Inheritance being one: for example en_DE -> en_150 -> en_001 -> en -> root in CLDR but en-DE -> en in BCP 47, and sr_Latn -> root in CLDR but sr-Latn -> sr in BCP 47 (CLDR has set rules, BCP 47 just goes up a level).

And then there's differences like:

  • zh-cmn-Hans-CN (Chinese, Mandarin, Simplified script, as used in China)
  • cmn-Hans-CN (Mandarin Chinese, Simplified script, as used in China)
  • zh-yue-HK (Chinese, Cantonese, as used in Hong Kong SAR)
  • yue-HK (Cantonese Chinese, as used in Hong Kong SAR)
  • zh-Hans-CN (Chinese written using the Simplified script as used in mainland China)

So, this uses the CLDR data to get a list of locales, produces a map of parents based on the BCP 47 rule, then uses the CLDR data to work out the right value for every level. It then works out what's superfluous, which is most of it (eg en-GB has the same value as en so isn't needed, but en is the same as the default value so also isn't).


&:lang(ja):after {
content: "、";
@each $locale, $separator in $list-separators {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do with a comment describing where $list-separators comes from.


const cleanSassLocaleData = () => del([config.files.src.sassLocales]);

const generateSassLocaleData = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth extracting (at least some of) this into a module. There's quite a bit going on here, and that would make it more testable.

@include nospace("inline-start");
}

@mixin inline-list-item() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did wonder about including this in inline-list() using &__item.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'n not too keen on partial selectors, because they can get missed during refactoring.

@thewilkybarkid
Copy link
Contributor Author

Can add final ellipsis characters

&:lang(zh-Hant-HK) {
text-overflow: "";
}
though it appears that the CLDR data is partial.

@thewilkybarkid thewilkybarkid requested a review from a team as a code owner July 16, 2019 15:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants