File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,13 @@ async function loadLocale(locale) {
3737}
3838
3939export async function setLocale ( locale ) {
40- translations = await loadLocale ( locale ) ;
41- setState ( { locale } ) ;
40+ // Strip region code (e.g. "en-US" → "en") since locale files use base language
41+ const baseLocale = locale . split ( "-" ) [ 0 ] . split ( "_" ) [ 0 ] ;
42+ translations = await loadLocale ( baseLocale ) ;
43+ setState ( { locale : baseLocale } ) ;
4244 applyTranslations ( ) ;
43- document . documentElement . lang = locale ;
44- document . documentElement . dir = RTL_LOCALES . has ( locale ) ? "rtl" : "ltr" ;
45+ document . documentElement . lang = baseLocale ;
46+ document . documentElement . dir = RTL_LOCALES . has ( baseLocale ) ? "rtl" : "ltr" ;
4547}
4648
4749export function t ( key ) {
You can’t perform that action at this time.
0 commit comments