Replace i18n by a custom implementation (#638)

There are two problems with the current localization strategy:
- We download the translations on-demand, which means that it does a serial roundtrip for nothing.
- withTranslation helper actually renders the app 3 times on startup, instead of once (I haven't tried to debug it)
This commit is contained in:
Christopher Chedeau 2020-01-31 21:06:06 +00:00 committed by GitHub
parent 637276301a
commit e4919e2e6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 101 additions and 167 deletions

View file

@ -1,22 +1,20 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { t } from "../i18n";
export function LanguageList<T>({
onClick,
onChange,
languages,
currentLanguage,
}: {
languages: { lng: string; label: string }[];
onClick: (value: string) => void;
onChange: (value: string) => void;
currentLanguage: string;
}) {
const { t } = useTranslation();
return (
<React.Fragment>
<select
className="language-select"
onChange={({ target }) => onClick(target.value)}
onChange={({ target }) => onChange(target.value)}
value={currentLanguage}
aria-label={t("buttons.selectLanguage")}
>