fix: Correct HTML lang attribute in source. closes #6534
This commit is contained in:
@@ -6,6 +6,7 @@ import escape from "lodash/escape";
|
|||||||
import { Sequelize } from "sequelize";
|
import { Sequelize } from "sequelize";
|
||||||
import isUUID from "validator/lib/isUUID";
|
import isUUID from "validator/lib/isUUID";
|
||||||
import { IntegrationType, TeamPreference } from "@shared/types";
|
import { IntegrationType, TeamPreference } from "@shared/types";
|
||||||
|
import { unicodeCLDRtoISO639 } from "@shared/utils/date";
|
||||||
import documentLoader from "@server/commands/documentLoader";
|
import documentLoader from "@server/commands/documentLoader";
|
||||||
import env from "@server/env";
|
import env from "@server/env";
|
||||||
import { Integration } from "@server/models";
|
import { Integration } from "@server/models";
|
||||||
@@ -91,6 +92,7 @@ export const renderApp = async (
|
|||||||
ctx.body = page
|
ctx.body = page
|
||||||
.toString()
|
.toString()
|
||||||
.replace(/\{env\}/g, environment)
|
.replace(/\{env\}/g, environment)
|
||||||
|
.replace(/\{lang\}/g, unicodeCLDRtoISO639(env.DEFAULT_LANGUAGE))
|
||||||
.replace(/\{title\}/g, escape(title))
|
.replace(/\{title\}/g, escape(title))
|
||||||
.replace(/\{description\}/g, escape(description))
|
.replace(/\{description\}/g, escape(description))
|
||||||
.replace(/\{canonical-url\}/g, canonical)
|
.replace(/\{canonical-url\}/g, canonical)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="{lang}">
|
||||||
<head>
|
<head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<meta name="theme-color" content="#FFF" />
|
<meta name="theme-color" content="#FFF" />
|
||||||
|
|||||||
@@ -106,6 +106,16 @@ export function unicodeBCP47toCLDR(locale: string) {
|
|||||||
return locale.replace("-", "_").replace("und", "root");
|
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.
|
* Returns the current date as a string formatted depending on current locale.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user