Skip to content

Commit

Permalink
feat(i18n): localize footer widget
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-kirill committed Aug 30, 2024
1 parent c70c3e1 commit 4b05dd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions client/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const I18N_INSTRUMENT_BASIC_MATERIALS = "instrument.basic.materials";
export const I18N_INSTRUMENT_DATE_FROM = "instrument.date.from";
export const I18N_INSTRUMENT_DATE_TO = "instrument.date.to";

export const I18N_FOOTER = "footer";

const resources = {
en: {
translation: {
Expand All @@ -51,7 +53,9 @@ const resources = {
[I18N_COUNTRY]: "Country",
[I18N_INSTRUMENT_BASIC_MATERIALS]: "Basic Materials",
[I18N_INSTRUMENT_DATE_FROM]: "From",
[I18N_INSTRUMENT_DATE_TO]: "To"
[I18N_INSTRUMENT_DATE_TO]: "To",

[I18N_FOOTER]: "Muse Group Frontend Academy",
}
},
ru: {
Expand All @@ -76,7 +80,7 @@ const resources = {
[I18N_COUNTRY]: "Страна",
[I18N_INSTRUMENT_BASIC_MATERIALS]: "Основные материалы",
[I18N_INSTRUMENT_DATE_FROM]: "С",
[I18N_INSTRUMENT_DATE_TO]: "По"
[I18N_INSTRUMENT_DATE_TO]: "По",
}
}
};
Expand All @@ -86,6 +90,7 @@ i18n
.init({
resources,
lng: window.navigator.language,
fallbackLng: "en",
interpolation: {
escapeValue: false // react already safes from xss
}
Expand Down
5 changes: 4 additions & 1 deletion client/src/widgets/footer/ui/Footer.widget.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from "react";
import styles from "./styles/Footer.widget.module.css";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";
import { useTranslation } from "react-i18next";
import { I18N_FOOTER } from "../../../i18n";

export function FooterWidget() {
const { t } = useTranslation();
const { darkMode } = useDarkMode();

return (
Expand All @@ -12,7 +15,7 @@ export function FooterWidget() {
${darkMode && styles.footer__dark}
`}
>
Muse Group Frontend Academy
{t(I18N_FOOTER)}
</footer>
);
}
Expand Down

0 comments on commit 4b05dd6

Please sign in to comment.