excalidraw/src/components/LanguageList.tsx
Christopher Chedeau e4919e2e6c
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)
2020-01-31 21:06:06 +00:00

30 lines
687 B
TypeScript

import React from "react";
import { t } from "../i18n";
export function LanguageList<T>({
onChange,
languages,
currentLanguage,
}: {
languages: { lng: string; label: string }[];
onChange: (value: string) => void;
currentLanguage: string;
}) {
return (
<React.Fragment>
<select
className="language-select"
onChange={({ target }) => onChange(target.value)}
value={currentLanguage}
aria-label={t("buttons.selectLanguage")}
>
{languages.map(language => (
<option key={language.lng} value={language.lng}>
{language.label}
</option>
))}
</select>
</React.Fragment>
);
}