Show alternative languages in own list.

This commit is contained in:
Paul 2021-06-22 16:37:06 +01:00
parent 22b21c030f
commit 99572066c8
4 changed files with 51 additions and 29 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit a84270a2b941a51f4785e543c0882ce9f7f004a6 Subproject commit 332cc2d7125b9cfb26ce211a9cb0fbf29301946c

View file

@ -51,6 +51,7 @@ export interface LanguageEntry {
i18n: string; i18n: string;
dayjs?: string; dayjs?: string;
rtl?: boolean; rtl?: boolean;
alt?: boolean;
} }
export const Languages: { [key in Language]: LanguageEntry } = { export const Languages: { [key in Language]: LanguageEntry } = {
@ -95,20 +96,22 @@ export const Languages: { [key in Language]: LanguageEntry } = {
dayjs: "zh", dayjs: "zh",
}, },
owo: { display: "OwO", emoji: "🐱", i18n: "owo", dayjs: "en-gb" }, owo: { display: "OwO", emoji: "🐱", i18n: "owo", dayjs: "en-gb", alt: true },
pr: { display: "Pirate", emoji: "🏴‍☠️", i18n: "pr", dayjs: "en-gb" }, pr: { display: "Pirate", emoji: "🏴‍☠️", i18n: "pr", dayjs: "en-gb", alt: true },
bottom: { display: "Bottom", emoji: "🥺", i18n: "bottom", dayjs: "en-gb" }, bottom: { display: "Bottom", emoji: "🥺", i18n: "bottom", dayjs: "en-gb", alt: true },
piglatin: { piglatin: {
display: "Pig Latin", display: "Pig Latin",
emoji: "🐖", emoji: "🐖",
i18n: "piglatin", i18n: "piglatin",
dayjs: "en-gb", dayjs: "en-gb",
alt: true
}, },
hardcore: { hardcore: {
display: "Hardcore Mode", display: "Hardcore Mode",
emoji: "🔥", emoji: "🔥",
i18n: "hardcore", i18n: "hardcore",
dayjs: "en-gb", dayjs: "en-gb",
alt: true
}, },
}; };

View file

@ -7,19 +7,13 @@ import { connectState } from "../../../redux/connector";
import { WithDispatcher } from "../../../redux/reducers"; import { WithDispatcher } from "../../../redux/reducers";
import { Language, LanguageEntry, Languages as Langs } from "../../../context/Locale"; import { Language, LanguageEntry, Languages as Langs } from "../../../context/Locale";
interface Props { type Props = WithDispatcher & {
locale: Language; locale: Language;
} }
export function Component({ locale, dispatcher }: Props & WithDispatcher) { type Key = [ string, LanguageEntry ];
return (
<div className={styles.languages}> function Entry({ entry: [ x, lang ], locale, dispatcher }: { entry: Key } & Props) {
<h3>
<Text id="app.settings.pages.language.select" />
</h3>
<div className={styles.list}>
{Object.keys(Langs).map(x => {
const l = (Langs as any)[x] as LanguageEntry;
return ( return (
<Checkbox <Checkbox
key={x} key={x}
@ -34,13 +28,36 @@ export function Component({ locale, dispatcher }: Props & WithDispatcher) {
} }
}} }}
> >
<div className={styles.flag}><Emoji size={42} emoji={l.emoji} /></div> <div className={styles.flag}><Emoji size={42} emoji={lang.emoji} /></div>
<span className={styles.description}> <span className={styles.description}>
{l.display} {lang.display}
</span> </span>
</Checkbox> </Checkbox>
); );
})} }
export function Component(props: Props) {
const languages = Object
.keys(Langs)
.map(x => [ x, Langs[x as keyof typeof Langs] ]) as Key[];
return (
<div className={styles.languages}>
<h3>
<Text id="app.settings.pages.language.select" />
</h3>
<div className={styles.list}>
{languages
.filter(([, lang]) => !lang.alt)
.map(([x, lang]) => <Entry key={x} entry={[x, lang]} {...props} />)}
</div>
<h3>
<Text id="app.settings.pages.language.other" />
</h3>
<div className={styles.list}>
{languages
.filter(([, lang]) => lang.alt)
.map(([x, lang]) => <Entry key={x} entry={[x, lang]} {...props} />)}
</div> </div>
<Tip> <Tip>
<span> <span>

View file

@ -336,6 +336,8 @@
.languages { .languages {
.list { .list {
margin-bottom: 1em;
.entry { .entry {
padding: 2px 8px; padding: 2px 8px;
height: 50px; height: 50px;