diff --git a/src/i18n.js b/src/i18n.js index bd7e3a122..3f4e98de3 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -75,11 +75,20 @@ export function currentLocale() { if (locale in messages) { return locale; } - // some locales are further specified such as "en-US". - // If we only have a generic locale for this, we can use it too - const genericLocale = locale.split("-")[0]; - if (genericLocale in messages) { - return genericLocale; + // If the locale is a 2-letter code, we can try to find a regional variant + // e.g. "fr" may not be in the messages, but "fr-FR" is + if (locale.length === 2) { + const regionalLocale = `${locale}-${locale.toUpperCase()}`; + if (regionalLocale in messages) { + return regionalLocale; + } + } else { + // Some locales are further specified such as "en-US". + // If we only have a generic locale for this, we can use it too + const genericLocale = locale.slice(0, 2); + if (genericLocale in messages) { + return genericLocale; + } } } return "en"; diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 17d32365c..1d068b92e 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -9,7 +9,8 @@
{{ monitor.id }}
-

{{ monitor.description }}

+ +

@@ -285,6 +286,8 @@ import Tag from "../components/Tag.vue"; import CertificateInfo from "../components/CertificateInfo.vue"; import { getMonitorRelativeURL } from "../util.ts"; import { URL } from "whatwg-url"; +import DOMPurify from "dompurify"; +import { marked } from "marked"; import { getResBaseURL } from "../util-frontend"; import { highlight, languages } from "prismjs/components/prism-core"; import "prismjs/components/prism-clike"; @@ -399,6 +402,14 @@ export default { screenshotURL() { return getResBaseURL() + this.monitor.screenshot + "?time=" + this.cacheTime; + }, + + descriptionHTML() { + if (this.monitor.description != null) { + return DOMPurify.sanitize(marked(this.monitor.description)); + } else { + return ""; + } } },