diff --git a/server/routes/app.ts b/server/routes/app.ts index 6731dcc6d..3c0266fb5 100644 --- a/server/routes/app.ts +++ b/server/routes/app.ts @@ -6,6 +6,7 @@ import escape from "lodash/escape"; import { Sequelize } from "sequelize"; import isUUID from "validator/lib/isUUID"; import { IntegrationType, TeamPreference } from "@shared/types"; +import { unicodeCLDRtoISO639 } from "@shared/utils/date"; import documentLoader from "@server/commands/documentLoader"; import env from "@server/env"; import { Integration } from "@server/models"; @@ -91,6 +92,7 @@ export const renderApp = async ( ctx.body = page .toString() .replace(/\{env\}/g, environment) + .replace(/\{lang\}/g, unicodeCLDRtoISO639(env.DEFAULT_LANGUAGE)) .replace(/\{title\}/g, escape(title)) .replace(/\{description\}/g, escape(description)) .replace(/\{canonical-url\}/g, canonical) diff --git a/server/static/index.html b/server/static/index.html index 73cf7c9c5..2b6ec8dc0 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -1,5 +1,5 @@ - + {title} diff --git a/shared/utils/date.ts b/shared/utils/date.ts index 9dad4cd69..dcd9ed1eb 100644 --- a/shared/utils/date.ts +++ b/shared/utils/date.ts @@ -106,6 +106,16 @@ export function unicodeBCP47toCLDR(locale: string) { return locale.replace("-", "_").replace("und", "root"); } +/** + * Converts a locale string from Unicode CLDR format to ISO 639 format. + * + * @param locale The locale string to convert + * @returns The converted locale string + */ +export function unicodeCLDRtoISO639(locale: string) { + return locale.split("_")[0]; +} + /** * Returns the current date as a string formatted depending on current locale. *