From 8cf1efbcb7e8efa63c951e3ca75411cfac2714bd Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 16 Jul 2021 14:29:22 -0400 Subject: [PATCH] Adding a few missing langs. (#325) * Adding a few missing langs. * Remove unused extra language issue. --- src/server/index.tsx | 16 +++------------- src/shared/i18next.ts | 8 +++++++- src/shared/interfaces.ts | 3 --- src/shared/utils.ts | 9 +++++++++ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 2d2a662..57c5964 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -76,20 +76,10 @@ server.get("/*", async (req, res) => { return res.redirect(`/404?err=${errCode}`); } - let acceptLang = req.headers["accept-language"] - ? req.headers["accept-language"].split(",")[0] - : "en"; - let lang = site.my_user - ? site.my_user.local_user.lang == "browser" - ? acceptLang - : "en" - : acceptLang; - let isoData: IsoData = { path: req.path, site_res: site, routeData, - lang, }; const wrapper = ( @@ -160,9 +150,9 @@ server.listen(Number(port), hostname, () => { console.log(`http://${hostname}:${port}`); }); -function setForwardedHeaders( - headers: IncomingHttpHeaders -): { [key: string]: string } { +function setForwardedHeaders(headers: IncomingHttpHeaders): { + [key: string]: string; +} { let out = { host: headers.host, }; diff --git a/src/shared/i18next.ts b/src/shared/i18next.ts index 0bb85ae..6db9dd1 100644 --- a/src/shared/i18next.ts +++ b/src/shared/i18next.ts @@ -35,6 +35,9 @@ import { th } from "./translations/th"; import { bg } from "./translations/bg"; import { ar } from "./translations/ar"; import { ko } from "./translations/ko"; +import { id } from "./translations/id"; +import { nb_NO } from "./translations/nb_NO"; +import { zh_Hant } from "./translations/zh_Hant"; // https://github.com/nimbusec-oss/inferno-i18next/blob/master/tests/T.test.js#L66 const resources = { @@ -72,7 +75,10 @@ const resources = { th, bg, ar, - ko + ko, + id, + nb_NO, + zh_Hant, }; function format(value: any, format: any): any { diff --git a/src/shared/interfaces.ts b/src/shared/interfaces.ts index d4477b7..e09f3bd 100644 --- a/src/shared/interfaces.ts +++ b/src/shared/interfaces.ts @@ -9,9 +9,6 @@ export interface IsoData { path: string; routeData: any[]; site_res: GetSiteResponse; - // Lang and theme - lang: string; - // communities?: ListCommunitiesResponse; } export interface ILemmyConfig { diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 7298311..2510b95 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -29,6 +29,8 @@ import "moment/locale/ko"; import "moment/locale/da"; import "moment/locale/hr"; import "moment/locale/bg"; +import "moment/locale/id"; +import "moment/locale/nb"; import { UserOperation, @@ -106,6 +108,7 @@ export const languages = [ { code: "gl" }, { code: "hr" }, { code: "hu" }, + { code: "id" }, { code: "ka" }, { code: "ko" }, { code: "km" }, @@ -113,6 +116,7 @@ export const languages = [ { code: "fa" }, { code: "ja" }, { code: "oc" }, + { code: "nb_NO" }, { code: "pl" }, { code: "pt_BR" }, { code: "zh" }, @@ -128,6 +132,7 @@ export const languages = [ { code: "nl" }, { code: "it" }, { code: "bg" }, + { code: "zh_Hant" }, ]; export const themes = [ @@ -458,6 +463,10 @@ export function getMomentLanguage(): string { lang = "th"; } else if (lang.startsWith("bg")) { lang = "bg"; + } else if (lang.startsWith("id")) { + lang = "id"; + } else if (lang.startsWith("nb")) { + lang = "nb"; } else { lang = "en"; } -- 2.44.1