Skip to content

Commit bf1a056

Browse files
STERICMS-910 if no page metada exists fallback to URL for get locale
1 parent 5f3eba5 commit bf1a056

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

scripts/scripts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ export function getLocale() {
126126
if (locale && locale.length > 0) {
127127
return locale;
128128
}
129+
// no locale metadata (e.g. the static 404 page): fall back to the URL path
130+
const pathLocale = window.location.pathname.split('/')[1];
131+
if (/^[a-z]{2}-[a-z]{2}$/.test(pathLocale)) {
132+
return pathLocale;
133+
}
129134
// defaulting to en-us
130135
return 'en-us';
131136
}

0 commit comments

Comments
 (0)