Skip to content

Commit 76ecc5a

Browse files
authored
UX: normalize locale (#86)
1 parent 58573c4 commit 76ecc5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

javascripts/discourse/components/custom-header-links.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Component from "@glimmer/component";
22
import { dasherize } from "@ember/string";
33

4+
function normalizeLocale(locale) {
5+
return locale?.trim().toLowerCase().replace(/[-_]/g, "_");
6+
}
47
export default class CustomHeaderLinks extends Component {
58
get shouldShow() {
69
return settings.custom_header_links?.length > 0;
@@ -16,7 +19,9 @@ export default class CustomHeaderLinks extends Component {
1619
const locale = link.locale;
1720
const device = link.view;
1821

19-
if (!linkText || (locale && document.documentElement.lang !== locale)) {
22+
const currentLocale = normalizeLocale(document.documentElement.lang);
23+
24+
if (!linkText || (locale && normalizeLocale(locale) !== currentLocale)) {
2025
return result;
2126
}
2227

0 commit comments

Comments
 (0)