Front/translate refactor (#110)
* Front: i18n: Create component * Front: Use new translation component * Front: Translation COmpoent: Change props name * Front: Fix merge
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { translate } from "../i18n/i18n";
|
||||
import { en } from "../i18n/Translations";
|
||||
import { RootState, useSelector } from "../state/Store";
|
||||
|
||||
type TranslateProps = {
|
||||
translationKey: keyof typeof en;
|
||||
format?: (translated: string) => string;
|
||||
}
|
||||
/**
|
||||
* Translation component
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
const Translate = ({ translationKey, format }: TranslateProps) => {
|
||||
const selectedLanguage = useSelector((state: RootState) => state.language.value);
|
||||
const translated = translate(translationKey, selectedLanguage);
|
||||
return <>{format ? format(translated) : translated}</>;
|
||||
}
|
||||
|
||||
export default Translate;
|
||||
Reference in New Issue
Block a user