Skip to content

Commit ec0d136

Browse files
committed
fix invalid_argument in DisplayNames.of
1 parent 6bd7c78 commit ec0d136

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
"build": "vite build && vue-tsc -d --emitDeclarationOnly"
1212
},
1313
"devDependencies": {
14-
"@antfu/eslint-config": "^4.12.0",
15-
"@vitejs/plugin-vue": "^5.2.3",
16-
"eslint": "^9.24.0",
14+
"@antfu/eslint-config": "^4.13.0",
15+
"@vitejs/plugin-vue": "^5.2.4",
16+
"eslint": "^9.26.0",
1717
"fcitx5-js": "file:cache/fcitx5-js.tgz",
1818
"naive-ui": "^2.41.0",
1919
"typescript": "5.8.3",
20-
"vite": "^6.2.6",
20+
"vite": "^6.3.5",
2121
"vooks": "^0.2.12",
2222
"vue": "^3.5.13",
2323
"vue-i18n": "11",
24-
"vue-tsc": "^2.2.8"
24+
"vue-tsc": "^2.2.10"
2525
}
2626
}

src/InputMethodConfig.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import PlusButton from './PlusButton.vue'
1010
import { extractValue } from './util'
1111
1212
const languageName = new Intl.DisplayNames(navigator.language, { type: 'language' })
13+
14+
function getNameOf(code: string) {
15+
try {
16+
return languageName.of(code) ?? code
17+
}
18+
catch { // e.g. code === '*' (m17n math-latex)
19+
return code
20+
}
21+
}
1322
</script>
1423

1524
<script setup lang="ts">
@@ -93,8 +102,8 @@ watchEffect(() => {
93102
if (!b) {
94103
return -1
95104
}
96-
const la = languageName.of(a) ?? a
97-
const lb = languageName.of(b) ?? b
105+
const la = getNameOf(a)
106+
const lb = getNameOf(b)
98107
if (a === la && b !== lb) {
99108
return 1
100109
}
@@ -105,7 +114,7 @@ watchEffect(() => {
105114
})
106115
for (const languageCode of sortedLanguageCodes) {
107116
languageOptions.value.push({
108-
label: languageCode ? (languageName.of(languageCode) ?? languageCode) : 'Unknown',
117+
label: languageCode ? getNameOf(languageCode) : 'Unknown',
109118
key: languageCode,
110119
})
111120
}

0 commit comments

Comments
 (0)