mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
fix: avoid stringifying locale objects
Change-Id: Ic9557acc384d5a23b3cbaaae9fea2678e9afd661
This commit is contained in:
parent
2faf1729f2
commit
c45f7987e3
2 changed files with 5 additions and 4 deletions
|
|
@ -6,10 +6,10 @@ import type { PluginSettings } from './types';
|
|||
export { LOCALE_OVERRIDES, STRINGS } from './i18n-strings';
|
||||
|
||||
function supportedBaseLanguage(value: unknown): string | null {
|
||||
const base = String(value || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.split(/[-_]/)[0];
|
||||
if (typeof value !== 'string') {
|
||||
return null;
|
||||
}
|
||||
const base = value.trim().toLowerCase().split(/[-_]/)[0];
|
||||
return base && STRINGS[base] ? base : null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ const { assert, requireBundledModule, cleanup } = require('./direct-test-setup')
|
|||
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'es' }), 'es');
|
||||
assert.strictEqual(i18n.resolveUiLanguage(null), 'en');
|
||||
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: 'auto' }), 'en');
|
||||
assert.strictEqual(i18n.resolveUiLanguage({ uiLanguage: { toString: () => 'ja' } }), 'en');
|
||||
|
||||
const originalNavigator = Object.getOwnPropertyDescriptor(globalThis, 'navigator');
|
||||
const setNavigatorLanguage = (language) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue