Created navbar ru localization

This commit is contained in:
Daniel Weissmall 2022-10-14 10:29:23 +03:00
parent c99e9217f1
commit 3f9a76815e
6 changed files with 89 additions and 50 deletions

View File

@ -59,5 +59,29 @@
"services": { "services": {
"fork": "Не удалось выполнить авторизацию в сервисе" "fork": "Не удалось выполнить авторизацию в сервисе"
} }
},
"articlePage": {
"abstract": "Введение",
"keywords": "Ключевые слова"
},
"navbar": {
"createNew": "Создать статью",
"about": {
"navTitle": "О проекте",
"aboutProject": "О Scipaper",
"contacts": "Контакты",
"help": "Помощь"
},
"library": {
"navTitle": "Моя библиотека",
"publications": "Публикации",
"favorites": "Избранное",
"collections": "Коллекции",
"recentViewed": "История"
},
"auth": {
"signIn": "Вход",
"signUp": "Регистрация"
}
} }
} }

View File

@ -37,7 +37,7 @@ export const ArticleSearchResult = ({ searchItem }: Props) => {
<Article.SubscriptionsButtons /> <Article.SubscriptionsButtons />
</div> </div>
<Article.Title linkTo={searchItem.id} className="text-2xl"> <Article.Title linkTo={`/article/${searchItem.id}`} className="text-2xl">
{searchItem.title} {searchItem.title}
</Article.Title> </Article.Title>
<Article.Authors emphasis="low" className="flex flex-wrap flex-row"> <Article.Authors emphasis="low" className="flex flex-wrap flex-row">

View File

@ -8,10 +8,13 @@ import Container from "components/Container";
import NotFound from "./NotFound"; import NotFound from "./NotFound";
import { SVGSearch } from "components/icons"; import { SVGSearch } from "components/icons";
import BaseLayout from "components/BaseLayout"; import BaseLayout from "components/BaseLayout";
import Typography from "components/typography/Typography";
import { useTranslation } from "react-i18next";
const AnArticle = () => { const AnArticle = () => {
const store = useArticleStore(); const store = useArticleStore();
const { article, hasError, shouldShowLoading } = useArticleViewModel(store); const { article, hasError, shouldShowLoading } = useArticleViewModel(store);
const { i18n, t } = useTranslation();
const { id } = useParams(); const { id } = useParams();
const newId = `${id}`; const newId = `${id}`;
@ -46,9 +49,13 @@ const AnArticle = () => {
<ArticlePart.Article.InteractionButtons emphasis="high" /> <ArticlePart.Article.InteractionButtons emphasis="high" />
{article?.tags && ( {article?.tags && (
<div className="keywords my-10 flex flex-col gap-2"> <div className="keywords my-10 flex flex-col gap-2">
<ArticlePart.Article.Title className="text-2xl"> <Typography
Keywords className="text-2xl"
</ArticlePart.Article.Title> fontWeightVariant="semibold"
>
{t('articlePage.keywords')}
</Typography>
<ArticlePart.Article.Keywords className="transition ease-in-out delay-50"> <ArticlePart.Article.Keywords className="transition ease-in-out delay-50">
{article?.tags} {article?.tags}
@ -56,9 +63,12 @@ const AnArticle = () => {
</div> </div>
)} )}
<div className="abstract my-10 flex flex-col gap-2"> <div className="abstract my-10 flex flex-col gap-2">
<ArticlePart.Article.Title className="text-2xl"> <Typography
Abstract className="text-2xl"
</ArticlePart.Article.Title> fontWeightVariant="semibold"
>
{t('articlePage.abstract')}
</Typography>
<ArticlePart.Article.Description> <ArticlePart.Article.Description>
{article?.summary !== undefined ? ( {article?.summary !== undefined ? (
article?.summary article?.summary

View File

@ -1,5 +1,5 @@
import classNames from "classnames"; import classNames from "classnames";
import { useState } from "react"; import { useState, useTransition } from "react";
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* Components */ /* Components */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@ -23,11 +23,14 @@ import {
SVGFile, SVGFile,
SVGEye, SVGEye,
} from "components/icons"; } from "components/icons";
import i18n from "localization/i18n";
import { useTranslation } from "react-i18next";
const Header = () => { const Header = () => {
const [authenticated, setAuthenticated] = useState(false); const [authenticated, setAuthenticated] = useState(false);
const onClick = () => setAuthenticated(true); const onClick = () => setAuthenticated(true);
const [notification, setNotification] = useState(false); const [notification, setNotification] = useState(false);
const { t, i18n } = useTranslation();
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* Implement Header Component */ /* Implement Header Component */
@ -66,36 +69,36 @@ const Header = () => {
className="text-blue-500 px-4 font-bold uppercase" className="text-blue-500 px-4 font-bold uppercase"
to="/create-new" to="/create-new"
> >
Create new {t('navbar.createNew')}
</RouterLink> </RouterLink>
{/* Link Create now - end - */} {/* Link Create now - end - */}
{/* Dropdown Menu My library - start - */} {/* Dropdown Menu My library - start - */}
<ContextMenu <ContextMenu
emphasis="high" emphasis="high"
button="My library" button={t('navbar.library.navTitle')}
className="border-none uppercase" className="border-none uppercase"
> >
<ContextMenuAction <ContextMenuAction
caption="My Publications" caption={t('navbar.library.publications')}
action={() => console.log("My publications")} action={() => console.log("My publications")}
icon={<SVGFile className="stroke-black " />} icon={<SVGFile className="stroke-black " />}
></ContextMenuAction> ></ContextMenuAction>
<ContextMenuAction <ContextMenuAction
caption="My Favorites" caption={t('navbar.library.favorites')}
action={() => console.log("My Favorites")} action={() => console.log("My Favorites")}
icon={<SVGFavoriteOutlined className="stroke-black" />} icon={<SVGFavoriteOutlined className="stroke-black" />}
></ContextMenuAction> ></ContextMenuAction>
<ContextMenuAction <ContextMenuAction
caption="My Collections" caption={t('navbar.library.collections')}
action={() => console.log("My Collections")} action={() => console.log("My Collections")}
icon={<SVGFolder className="stroke-black fill-black" />} icon={<SVGFolder className="stroke-black fill-black" />}
></ContextMenuAction> ></ContextMenuAction>
<ContextMenuAction <ContextMenuAction
caption="Recent Viewed" caption={t('navbar.library.recentViewed')}
action={() => console.log("Recent Viewed")} action={() => console.log("Recent Viewed")}
icon={<SVGEye className="stroke-black " />} icon={<SVGEye className="stroke-black " />}
></ContextMenuAction> ></ContextMenuAction>
@ -105,21 +108,21 @@ const Header = () => {
{/* Dropdown Menu About - start - */} {/* Dropdown Menu About - start - */}
<ContextMenu <ContextMenu
emphasis="high" emphasis="high"
button="About" button={t('navbar.about.navTitle')}
className="border-none uppercase" className="border-none uppercase"
> >
<ContextMenuAction <ContextMenuAction
caption="About Freeland" caption={t('navbar.about.aboutProject')}
action={() => console.log("About Freeland")} action={() => console.log("About Freeland")}
></ContextMenuAction> ></ContextMenuAction>
<ContextMenuAction <ContextMenuAction
caption="Contact Us" caption={t('navbar.about.contacts')}
action={() => console.log("Contact Us")} action={() => console.log("Contact Us")}
></ContextMenuAction> ></ContextMenuAction>
<ContextMenuAction <ContextMenuAction
caption="Help" caption={t('navbar.about.help')}
action={() => console.log("Help")} action={() => console.log("Help")}
></ContextMenuAction> ></ContextMenuAction>
</ContextMenu> </ContextMenu>
@ -137,14 +140,14 @@ const Header = () => {
onClick={onClick} onClick={onClick}
className="text-xs sm:px-4 sm:text-sm " className="text-xs sm:px-4 sm:text-sm "
> >
Sign in {t('navbar.auth.signIn')}
</Button>, </Button>,
<Button <Button
emphasis="medium" emphasis="medium"
className="hidden md:flex" className="hidden md:flex"
onClick={onClick} onClick={onClick}
> >
Sign up {t('navbar.auth.signUp')}
</Button>, </Button>,
] ]
: [ : [

View File

@ -16,6 +16,7 @@ import AccountSettings from "pages/Information/AccountSettings";
import { store } from "store/store"; import { store } from "store/store";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { SearchResultsPage } from "pages/SearchResultsPage"; import { SearchResultsPage } from "pages/SearchResultsPage";
import AnArticle from "components/fetchAnArticle/AnArticle";
const rootElement = document.getElementById("root"); const rootElement = document.getElementById("root");
if (!rootElement) throw new Error("Failed to find the root element"); if (!rootElement) throw new Error("Failed to find the root element");
@ -32,6 +33,7 @@ root.render(
<Route path="/terms-of-use" element={<TermsOfUse />} /> <Route path="/terms-of-use" element={<TermsOfUse />} />
<Route path="/privacy-policy" element={<PrivacyPolicy />} /> <Route path="/privacy-policy" element={<PrivacyPolicy />} />
<Route path="/cookies-policy" element={<CookiesPolicy />} /> <Route path="/cookies-policy" element={<CookiesPolicy />} />
<Route path="/article/:id" element={<AnArticle />} />
<Route path="/account"> <Route path="/account">
<Route path="settings" element={<AccountSettings />} /> <Route path="settings" element={<AccountSettings />} />
</Route> </Route>

View File

@ -18,11 +18,11 @@ export const languages: Record<Langs, Lang> = {
}, },
}; };
export const popularLangKeys = ["ru", "en"]; export const popularLangKeys = ["ru", "en"];
const fallbackLng: Langs = "en"; const fallbackLng: Langs = "ru";
i18n i18n
.use(Backend) .use(Backend)
.use(LanguageDetector) // .use(LanguageDetector)
.use(initReactI18next) .use(initReactI18next)
.init({ .init({
debug: process.env.NODE_ENV === "development" ? true : false, debug: process.env.NODE_ENV === "development" ? true : false,