mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
KeyboardLayoutService: better lang/country matching
This commit is contained in:
@@ -48,8 +48,16 @@ Singleton {
|
||||
}
|
||||
|
||||
// Check for language/country names in the language map
|
||||
// First, try to match at the start of the string (the primary language)
|
||||
for (const [lang, code] of Object.entries(languageMap)) {
|
||||
if (str.includes(lang)) {
|
||||
if (str.startsWith(lang)) {
|
||||
return code.toUpperCase();
|
||||
}
|
||||
}
|
||||
// Then try word boundary matching anywhere in the string
|
||||
for (const [lang, code] of Object.entries(languageMap)) {
|
||||
const regex = new RegExp(`\\b${lang}\\b`);
|
||||
if (regex.test(str)) {
|
||||
return code.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user