Skip to content

Commit

Permalink
Update locale display name strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds-signal committed Nov 14, 2023
1 parent 592a683 commit f180f66
Show file tree
Hide file tree
Showing 5 changed files with 4,837 additions and 84 deletions.
4,763 changes: 4,762 additions & 1 deletion build/locale-display-names.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions stylesheets/components/Preferences.scss
Expand Up @@ -310,7 +310,6 @@
}

.Preferences__LanguageButton {
text-transform: capitalize;
@include button-reset;
}

Expand Down Expand Up @@ -377,7 +376,6 @@

.Preferences__LanguageModal__Item__Current {
display: block;
text-transform: capitalize;
@include font-body-1;
}

Expand All @@ -399,7 +397,6 @@

.Preferences__LanguageModal__Item__Matching {
display: block;
text-transform: capitalize;
@include font-body-2;
@include light-theme {
color: $color-gray-60;
Expand Down
4 changes: 2 additions & 2 deletions ts/components/Preferences.tsx
Expand Up @@ -459,7 +459,7 @@ export function Preferences({
);

const localeSearchOptions = useMemo(() => {
const collator = new Intl.Collator(resolvedLocale, { usage: 'sort' });
const collator = new Intl.Collator('en', { usage: 'sort' });

const availableLocalesOptions = availableLocales
.map(locale => {
Expand All @@ -468,7 +468,7 @@ export function Preferences({
return { locale, currentLocaleLabel, matchingLocaleLabel };
})
.sort((a, b) => {
return collator.compare(a.currentLocaleLabel, b.currentLocaleLabel);
return collator.compare(a.locale, b.locale);
});

const [localeOverrideMatches, localeOverrideNonMatches] = partition(
Expand Down
11 changes: 4 additions & 7 deletions ts/scripts/build-locale-display-names.ts
Expand Up @@ -17,10 +17,7 @@ const LocaleString = z.string().refine(arg => {
});

const LocaleDisplayNames = z
.tuple([
z.tuple([z.literal('Raw Code')]).rest(LocaleString),
z.tuple([z.literal('Display Code')]).rest(LocaleString),
])
.tuple([z.tuple([z.literal('locale')]).rest(LocaleString)])
.rest(z.tuple([LocaleString]).rest(z.string()));

type Row = ReadonlyArray<string>;
Expand All @@ -39,7 +36,7 @@ const localeDisplayNamesBuildPath = path.join(

function parseCsv(input: string) {
return new Promise<Records>((resolve, reject) => {
parse(input, (error, records: Records) => {
parse(input, { trim: true }, (error, records: Records) => {
if (error) {
reject(error);
} else {
Expand All @@ -54,7 +51,7 @@ type LocaleDisplayNamesResult = Record<string, Record<string, string>>;
function convertData(
input: z.infer<typeof LocaleDisplayNames>
): LocaleDisplayNamesResult {
const [[, ...keys], , ...rows] = input;
const [[, ...keys], ...rows] = input;
const result = Object.fromEntries(
rows.map(row => {
const [key, ...messages] = row;
Expand Down Expand Up @@ -89,7 +86,7 @@ async function main() {
const data = LocaleDisplayNames.parse(records);
const result = convertData(data);
assertValuesForAllLocales(result);
const json = JSON.stringify(result);
const json = JSON.stringify(result, null, 2);
await fs.writeFile(localeDisplayNamesBuildPath, json, 'utf-8');
}

Expand Down

0 comments on commit f180f66

Please sign in to comment.