Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(i18n): localize footer widget #151

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading