Skip to content

Commit 211a406

Browse files
committed
used react-helmet to localize titles of static pages
1 parent 3819573 commit 211a406

File tree

14 files changed

+153
-12
lines changed

14 files changed

+153
-12
lines changed

web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"markdown-to-jsx": "^7.1.0",
2727
"react": "^17.0.1",
2828
"react-dom": "^17.0.1",
29+
"react-helmet": "^6.1.0",
2930
"react-redux": "^7.2.6",
3031
"react-router-dom": "^5.2.0",
3132
"react-spring": "^8.0.27",
@@ -52,6 +53,7 @@
5253
"@types/mini-css-extract-plugin": "^2.0.1",
5354
"@types/react": "^17.0.0",
5455
"@types/react-dom": "^17.0.0",
56+
"@types/react-helmet": "^6.1.5",
5557
"@types/react-redux": "^7.1.20",
5658
"@types/react-router-dom": "^5.1.6",
5759
"@types/react-syntax-highlighter": "^13.5.0",

web/src/apps/main/components/t/dictionary.ts

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ export const dictionary = {
3939
ar: "حقوق النشر ©",
4040
},
4141

42-
"faq-title": { en: "Frequently Asked Questions", ar: "اللاسئلة الاكثر طرحا" },
42+
"faq-title": {
43+
en: "Frequently Asked Questions | DzCode i/o",
44+
ar: "اللاسئلة الاكثر طرحا | DzCode i / o",
45+
},
46+
"faq-description": {
47+
en: "",
48+
ar: "",
49+
},
50+
"faq-header-title": { en: "Frequently Asked Questions", ar: "اللاسئلة الاكثر طرحا" },
4351
"faq-need-help": {
4452
en: "Still need help? send us an email at ",
4553
ar: "هل ما زلت بحاجة إلى المساعدة؟ أرسل إلينا بريدًا إلكترونيًا على ",
@@ -188,6 +196,14 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
188196
- ستحصل على مساهمات محتملة من مطورين آخرين ، مما سيجعل برنامجك في النهاية أفضل.
189197
`,
190198
},
199+
"landing-title": {
200+
en: "Algeria Codes | DzCode i/o",
201+
ar: "الجزائر تبرمج | DzCode i / o",
202+
},
203+
"landing-description": {
204+
en: "",
205+
ar: "",
206+
},
191207
"landing-heading-title": {
192208
en: `<span class="CLASS"}>Open-Source</span> Algerian Comunity`,
193209
ar: `مجموعة جزائرية للبرامج <span class="CLASS"}>مفتوحة المصدر</span>`,
@@ -212,6 +228,14 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
212228
en: "Meet the DzCode i/o mobile app and stay up-to-date with the state of Algerian open-source software on iOS and Android.",
213229
ar: "تعرف على تطبيق DzCode i / o للجوال وابق على اطلاع دائم بأحدث البرامج مفتوحة المصدر الجزائرية على iOS و Android.",
214230
},
231+
"team-title": {
232+
en: "Meet the team! | DzCode i/o",
233+
ar: "تعرّف على الفريق! | DzCode i / o",
234+
},
235+
"team-description": {
236+
en: "",
237+
ar: "",
238+
},
215239
"team-error": {
216240
en: "Oops, an error occurred while loading the articles list, please try again...",
217241
ar: "عفوًا ، حدث خطأ أثناء تحميل قائمة المقالات ، يرجى المحاولة مرة أخرى ...",
@@ -220,7 +244,7 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
220244
en: "Try Again",
221245
ar: "حاول مرة أخري",
222246
},
223-
"team-title": {
247+
"team-header-title": {
224248
en: "Get to know our team 💻",
225249
ar: "تعرف على فريقنا 💻",
226250
},
@@ -232,6 +256,14 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
232256
en: "Repositories",
233257
ar: "مستودعات",
234258
},
259+
"projects-title": {
260+
en: "Browse a growing list of Algerian open-source projects | DzCode i/o",
261+
ar: "تصفح قائمة المشاريع الجزائرية مفتوحة المصدر | DzCode i / o",
262+
},
263+
"projects-description": {
264+
en: "",
265+
ar: "",
266+
},
235267
"projects-error": {
236268
en: "Oops, an error occurred while loading the projects list, please try again...",
237269
ar: "عفوًا ، حدث خطأ أثناء تحميل قائمة المشاريع ، يرجى المحاولة مرة أخرى ...",
@@ -240,14 +272,22 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
240272
en: "Try Again",
241273
ar: "حاول مرة أخري",
242274
},
243-
"projects-title": {
275+
"projects-header-title": {
244276
en: "Open Source Projects",
245277
ar: "مشاريع مفتوحة المصدر",
246278
},
247279
"projects-card-cta-button": {
248280
en: "Go to code",
249281
ar: "إلى الكود",
250282
},
283+
"notfound-title": {
284+
en: "A broken link? | DzCode i/o",
285+
ar: "عنوان url معطل؟ | DzCode i / o",
286+
},
287+
"notfound-description": {
288+
en: "",
289+
ar: "",
290+
},
251291
"notfound-subtitle": {
252292
en: `Finally someone saw the 404 page <a href="https://github.com/NurElHuda">Nour</a> built 😄`,
253293
ar: `أخيرًا شاهد شخص ما صفحة 404 التي أنشأتها <a href="https://github.com/NurElHuda">نور</a> 😄`,
@@ -256,6 +296,14 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
256296
en: "Go Back Home",
257297
ar: "ارجع إلى الصفحة الرئيسية",
258298
},
299+
"contribute-title": {
300+
en: "Contribute to algerian open-source projects | DzCode i/o",
301+
ar: "ساهم في المشاريع الجزائرية مفتوحة المصدر | DzCode i / o",
302+
},
303+
"contribute-description": {
304+
en: "",
305+
ar: "",
306+
},
259307
"contribute-filter-projects": {
260308
en: "Project",
261309
ar: "المشروع",
@@ -280,4 +328,20 @@ Besides the open tasks on [/Contribute](/Contribute) page, you can also contribu
280328
en: "y|mo|d|h|min|Just now",
281329
ar: " عام| شهر| يوم| ساعة| دقيقة| الآن",
282330
},
331+
"articles-title": {
332+
en: "Read and discuss articles written by algerian developers | DzCode i/o",
333+
ar: "اقرأ وناقش المقالات التي كتبها المطورون الجزائريون | DzCode i / o",
334+
},
335+
"articles-description": {
336+
en: "",
337+
ar: "",
338+
},
339+
"learn-title": {
340+
en: "Learn about software development through open-source | DzCode i/o",
341+
ar: "تعرف على البرمجة من خلال البرامج مفتوحة المصدر | DzCode i / o",
342+
},
343+
"learn-description": {
344+
en: "",
345+
ar: "",
346+
},
283347
};

web/src/apps/main/entry/app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { allLanguages, LanguageEntity } from "@dzcode.io/models/dist/language";
44
import { ErrorBoundary } from "@dzcode.io/ui/dist/error-boundary";
55
import Container from "@material-ui/core/Container";
66
import { ComponentType, FC, lazy, Suspense, useEffect } from "react";
7+
import { Helmet } from "react-helmet";
78
import { useDispatch, useSelector } from "react-redux";
89
import { Route, RouteProps, Switch, useLocation, useRouteMatch } from "react-router-dom";
910
import { Footer } from "src/apps/main/components/footer";
1011
import { Navbar } from "src/apps/main/components/navbar";
12+
import { t } from "src/apps/main/components/t";
1113
import { Theme } from "src/apps/main/components/theme";
1214
import { getEnv } from "src/common/utils";
1315
import { urlLanguageRegEx } from "src/common/utils/language";
@@ -83,6 +85,9 @@ export const App: FC = () => {
8385
return (
8486
<Theme>
8587
<ErrorBoundary>
88+
<Helmet>
89+
<title>{t("landing-title")}</title>
90+
</Helmet>
8691
<div
8792
style={{
8893
display: "flex",

web/src/apps/main/pages/articles/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { TryAgain } from "@dzcode.io/ui/dist/try-again";
33
import { isLoaded } from "@dzcode.io/utils/dist/loadable";
44
import Grid from "@material-ui/core/Grid";
55
import { FC, useEffect, useState } from "react";
6+
import { Helmet } from "react-helmet";
67
import { useDispatch, useSelector } from "react-redux";
78
import { Route, useRouteMatch } from "react-router-dom";
89
import { Sidebar } from "src/apps/main/components/sidebar";
10+
import { t } from "src/apps/main/components/t";
911
import { Dispatch, StateInterface } from "src/apps/main/redux";
1012
import { fetchArticlesList } from "src/apps/main/redux/actions/articles-page";
1113
import { ArticlesPageState } from "src/apps/main/redux/reducers/articles-page";
@@ -30,6 +32,10 @@ export const ArticlesPage: FC = () => {
3032

3133
return (
3234
<ErrorBoundary>
35+
<Helmet>
36+
<title>{t("articles-title")}</title>
37+
<meta name="description" content={t("articles-description")} />
38+
</Helmet>
3339
<Grid container className="articles" dir="ltr">
3440
{/* Sidebar */}
3541
<Grid item xs={false} md={3} style={{ paddingTop: "1rem" }}>

web/src/apps/main/pages/contribute/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { ErrorBoundary } from "@dzcode.io/ui/dist/error-boundary";
22
import Grid from "@material-ui/core/Grid";
33
import { FC, useEffect } from "react";
4+
import { Helmet } from "react-helmet";
45
import { useDispatch } from "react-redux";
6+
import { t } from "src/apps/main/components/t";
57
import { ContributePageState } from "src/apps/main/redux/reducers/contribute-page";
68

79
import { Dispatch } from "../../redux";
@@ -17,6 +19,10 @@ export const ContributePage: FC = () => {
1719

1820
return (
1921
<ErrorBoundary>
22+
<Helmet>
23+
<title>{t("contribute-title")}</title>
24+
<meta name="description" content={t("contribute-description")} />
25+
</Helmet>
2026
<Grid container className="contribute-page" spacing={1}>
2127
{/* Filters */}
2228
<Grid item xs={false} md={3}>

web/src/apps/main/pages/faq/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Grid } from "@dzcode.io/ui/dist/grid";
44
import { ThemeProvider } from "@dzcode.io/ui/dist/theme/theme-provider";
55
import { Typography } from "@dzcode.io/ui/dist/typography";
66
import type { FC } from "react";
7+
import { Helmet } from "react-helmet";
78
import { useSelector } from "react-redux";
89
import { Markdown } from "src/apps/main/components/markdown";
910
import { T, t } from "src/apps/main/components/t";
@@ -15,6 +16,10 @@ const FaqCards = () => {
1516

1617
return (
1718
<Grid container rowSpacing={5}>
19+
<Helmet>
20+
<title>{t("faq-title")}</title>
21+
<meta name="description" content={t("faq-description")} />
22+
</Helmet>
1823
{faqData.map(({ title, questions }, index) => (
1924
<Grid item xs={12} key={`faq.title.${index}`}>
2025
<FaqCard
@@ -35,7 +40,7 @@ const FaqCards = () => {
3540
const PageTitle = () => {
3641
return (
3742
<Typography variant="h4" component="h1" textAlign="center">
38-
<T faq-title />
43+
<T faq-header-title />
3944
</Typography>
4045
);
4146
};

web/src/apps/main/pages/landing/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { ErrorBoundary } from "@dzcode.io/ui/dist/error-boundary";
22
import { FC } from "react";
3+
import { Helmet } from "react-helmet";
4+
import { t } from "src/apps/main/components/t";
35

46
import { Header } from "./header";
57
import { Mobile } from "./mobile";
68

79
export const LandingPage: FC = () => {
810
return (
911
<ErrorBoundary>
12+
<Helmet>
13+
<title>{t("landing-title")}</title>
14+
<meta name="description" content={t("landing-description")} />
15+
</Helmet>
1016
<Header />
1117
<Mobile />
1218
</ErrorBoundary>

web/src/apps/main/pages/learn/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TryAgain } from "@dzcode.io/ui/dist/try-again";
33
import { isLoaded } from "@dzcode.io/utils/dist/loadable";
44
import Grid from "@material-ui/core/Grid";
55
import { FC, useEffect, useState } from "react";
6+
import { Helmet } from "react-helmet";
67
import { useDispatch, useSelector } from "react-redux";
78
import { Route, useRouteMatch } from "react-router-dom";
89
import { Sidebar } from "src/apps/main/components/sidebar";
@@ -32,6 +33,10 @@ export const LearnPage: FC = () => {
3233

3334
return (
3435
<ErrorBoundary>
36+
<Helmet>
37+
<title>{t("learn-title")}</title>
38+
<meta name="description" content={t("learn-description")} />
39+
</Helmet>
3540
<Grid container className="learn" dir="ltr">
3641
{/* Sidebar */}
3742
<Grid item xs={false} md={3} style={{ paddingTop: "1rem" }}>

web/src/apps/main/pages/not-found/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Typography from "@material-ui/core/Typography";
55
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
66
import ArrowForwardIcon from "@material-ui/icons/ArrowForward";
77
import { FC } from "react";
8+
import { Helmet } from "react-helmet";
89
import { useSelector } from "react-redux";
910
import { LinkV2 } from "src/apps/main/components/link-v2";
1011
import { T, t } from "src/apps/main/components/t";
@@ -35,6 +36,10 @@ const NotFound: FC = () => {
3536

3637
return (
3738
<ErrorBoundary>
39+
<Helmet>
40+
<title>{t("notfound-title")}</title>
41+
<meta name="description" content={t("notfound-description")} />
42+
</Helmet>
3843
<div className={classes.root}>
3944
<img className={classes.image} src={svg} alt="DzCode i/o: 404 page not found" />
4045
<Typography className={classes.text}>

web/src/apps/main/pages/projects/catalog/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const Catalog: FC<CatalogProps> = ({ projectsList }) => {
2828
return (
2929
<>
3030
<Typography variant="h4" className={classes.header}>
31-
<T projects-title />
31+
<T projects-header-title />
3232
</Typography>
3333
<Grid container className={classes.root} spacing={4} justifyContent="space-around">
3434
{projectsList

0 commit comments

Comments
 (0)