From 99572066c885b369f3d2b23ee7ac07f999e625ea Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 22 Jun 2021 16:37:06 +0100 Subject: [PATCH] Show alternative languages in own list. --- external/lang | 2 +- src/context/Locale.tsx | 9 ++- src/pages/settings/panes/Languages.tsx | 67 ++++++++++++++-------- src/pages/settings/panes/Panes.module.scss | 2 + 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/external/lang b/external/lang index a84270a2..332cc2d7 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit a84270a2b941a51f4785e543c0882ce9f7f004a6 +Subproject commit 332cc2d7125b9cfb26ce211a9cb0fbf29301946c diff --git a/src/context/Locale.tsx b/src/context/Locale.tsx index df9b1eff..202a4cb6 100644 --- a/src/context/Locale.tsx +++ b/src/context/Locale.tsx @@ -51,6 +51,7 @@ export interface LanguageEntry { i18n: string; dayjs?: string; rtl?: boolean; + alt?: boolean; } export const Languages: { [key in Language]: LanguageEntry } = { @@ -95,20 +96,22 @@ export const Languages: { [key in Language]: LanguageEntry } = { dayjs: "zh", }, - owo: { display: "OwO", emoji: "🐱", i18n: "owo", dayjs: "en-gb" }, - pr: { display: "Pirate", emoji: "🏴‍☠️", i18n: "pr", dayjs: "en-gb" }, - bottom: { display: "Bottom", emoji: "🥺", i18n: "bottom", dayjs: "en-gb" }, + owo: { display: "OwO", emoji: "🐱", i18n: "owo", dayjs: "en-gb", alt: true }, + pr: { display: "Pirate", emoji: "🏴‍☠️", i18n: "pr", dayjs: "en-gb", alt: true }, + bottom: { display: "Bottom", emoji: "🥺", i18n: "bottom", dayjs: "en-gb", alt: true }, piglatin: { display: "Pig Latin", emoji: "🐖", i18n: "piglatin", dayjs: "en-gb", + alt: true }, hardcore: { display: "Hardcore Mode", emoji: "🔥", i18n: "hardcore", dayjs: "en-gb", + alt: true }, }; diff --git a/src/pages/settings/panes/Languages.tsx b/src/pages/settings/panes/Languages.tsx index 7e5566b3..e7ae6bf9 100644 --- a/src/pages/settings/panes/Languages.tsx +++ b/src/pages/settings/panes/Languages.tsx @@ -7,40 +7,57 @@ import { connectState } from "../../../redux/connector"; import { WithDispatcher } from "../../../redux/reducers"; import { Language, LanguageEntry, Languages as Langs } from "../../../context/Locale"; -interface Props { +type Props = WithDispatcher & { locale: Language; } -export function Component({ locale, dispatcher }: Props & WithDispatcher) { +type Key = [ string, LanguageEntry ]; + +function Entry({ entry: [ x, lang ], locale, dispatcher }: { entry: Key } & Props) { + return ( + { + if (v) { + dispatcher({ + type: "SET_LOCALE", + locale: x as Language + }); + } + }} + > +
+ + {lang.display} + +
+ ); +} + +export function Component(props: Props) { + const languages = Object + .keys(Langs) + .map(x => [ x, Langs[x as keyof typeof Langs] ]) as Key[]; + return (

- {Object.keys(Langs).map(x => { - const l = (Langs as any)[x] as LanguageEntry; - return ( - { - if (v) { - dispatcher({ - type: "SET_LOCALE", - locale: x as Language - }); - } - }} - > -
- - {l.display} - -
- ); - })} + {languages + .filter(([, lang]) => !lang.alt) + .map(([x, lang]) => )} +
+

+ +

+
+ {languages + .filter(([, lang]) => lang.alt) + .map(([x, lang]) => )}
diff --git a/src/pages/settings/panes/Panes.module.scss b/src/pages/settings/panes/Panes.module.scss index 56ef54f9..59fe76ce 100644 --- a/src/pages/settings/panes/Panes.module.scss +++ b/src/pages/settings/panes/Panes.module.scss @@ -336,6 +336,8 @@ .languages { .list { + margin-bottom: 1em; + .entry { padding: 2px 8px; height: 50px;