Skip to content

Commit

Permalink
feat(i18n): localize navbar widget
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-kirill committed Aug 30, 2024
1 parent e31becf commit b18233c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions client/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ 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_INSTRUMENT_CARD_SHOW_BUTTON = "instrument.card.show.button";

export const I18N_FOOTER = "footer";

export const I18N_NAVBAR_PREVIOUS = "navbar.previous";
export const I18N_NAVBAR_NEXT = "navbar.next";

const resources = {
en: {
translation: {
Expand All @@ -55,7 +60,12 @@ const resources = {
[I18N_INSTRUMENT_DATE_FROM]: "From",
[I18N_INSTRUMENT_DATE_TO]: "To",

[I18N_INSTRUMENT_CARD_SHOW_BUTTON]: "Show",

[I18N_FOOTER]: "Muse Group Frontend Academy",

[I18N_NAVBAR_PREVIOUS]: "Previous",
[I18N_NAVBAR_NEXT]: "Next",
}
},
ru: {
Expand All @@ -81,6 +91,11 @@ const resources = {
[I18N_INSTRUMENT_BASIC_MATERIALS]: "Основные материалы",
[I18N_INSTRUMENT_DATE_FROM]: "С",
[I18N_INSTRUMENT_DATE_TO]: "По",

[I18N_INSTRUMENT_CARD_SHOW_BUTTON]: "Показать",

[I18N_NAVBAR_PREVIOUS]: "Предыдущий",
[I18N_NAVBAR_NEXT]: "Следующий",
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import styles from "./styles/NavigationBar.widget.module.css";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";
import { useTranslation } from "react-i18next";
import { I18N_NAVBAR_NEXT, I18N_NAVBAR_PREVIOUS } from "../../../i18n";

interface Props {
totalPages: number;
Expand All @@ -9,6 +11,7 @@ interface Props {
}

export const NavigationBarWidget = (props: Props) => {
const { t } = useTranslation();
const { darkMode } = useDarkMode();

return (
Expand All @@ -25,7 +28,7 @@ export const NavigationBarWidget = (props: Props) => {
`}
onClick={() => props.setPageNumber(Math.max(1, props.pageNumber - 1))}
>
Previous
{t(I18N_NAVBAR_PREVIOUS)}
</button>

<button
Expand All @@ -37,7 +40,7 @@ export const NavigationBarWidget = (props: Props) => {
props.setPageNumber(Math.min(props.pageNumber + 1, props.totalPages))
}
>
Next
{t(I18N_NAVBAR_NEXT)}
</button>
</div>
);
Expand Down

0 comments on commit b18233c

Please sign in to comment.