mirror of
https://github.com/discourse/discourse-custom-header-links.git
synced 2025-07-01 10:52:10 +00:00
UX: normalize locale (#86)
This commit is contained in:
parent
58573c4f11
commit
76ecc5abb1
@ -1,6 +1,9 @@
|
|||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { dasherize } from "@ember/string";
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
|
function normalizeLocale(locale) {
|
||||||
|
return locale?.trim().toLowerCase().replace(/[-_]/g, "_");
|
||||||
|
}
|
||||||
export default class CustomHeaderLinks extends Component {
|
export default class CustomHeaderLinks extends Component {
|
||||||
get shouldShow() {
|
get shouldShow() {
|
||||||
return settings.custom_header_links?.length > 0;
|
return settings.custom_header_links?.length > 0;
|
||||||
@ -16,7 +19,9 @@ export default class CustomHeaderLinks extends Component {
|
|||||||
const locale = link.locale;
|
const locale = link.locale;
|
||||||
const device = link.view;
|
const device = link.view;
|
||||||
|
|
||||||
if (!linkText || (locale && document.documentElement.lang !== locale)) {
|
const currentLocale = normalizeLocale(document.documentElement.lang);
|
||||||
|
|
||||||
|
if (!linkText || (locale && normalizeLocale(locale) !== currentLocale)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user