mirror of
https://github.com/discourse/discourse-custom-header-links.git
synced 2025-06-30 18:32:27 +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 { dasherize } from "@ember/string";
|
||||
|
||||
function normalizeLocale(locale) {
|
||||
return locale?.trim().toLowerCase().replace(/[-_]/g, "_");
|
||||
}
|
||||
export default class CustomHeaderLinks extends Component {
|
||||
get shouldShow() {
|
||||
return settings.custom_header_links?.length > 0;
|
||||
@ -16,7 +19,9 @@ export default class CustomHeaderLinks extends Component {
|
||||
const locale = link.locale;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user