diff --git a/src/index.ts b/src/index.ts index 852eade..b801545 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,7 @@ const activeMessages: object = reactive({}) */ export function isLoaded(lang?: string): boolean { lang ??= getActiveLanguage() + lang = lang.replace('-', '_') return loaded.some((row) => row.lang === lang) } @@ -91,7 +92,11 @@ export function transChoice(key: string, number: number, replacements: Replaceme /** * Translates the given message based on a count and watch for changes. */ -export function wTransChoice(key: string, number: number, replacements: ReplacementsInterface = {}): ComputedRef { +export function wTransChoice( + key: string, + number: number, + replacements: ReplacementsInterface = {} +): ComputedRef { const message = wTrans(key, replacements) replacements.count = number.toString() diff --git a/test/translate.test.ts b/test/translate.test.ts index 4af6bf7..805ee96 100644 --- a/test/translate.test.ts +++ b/test/translate.test.ts @@ -90,9 +90,9 @@ it('checks if is a lang is loaded', async () => { expect(isLoaded()).toBe(false); await global.mountPlugin(); - expect(isLoaded('zh_TW')).toBe(false); - await loadLanguageAsync('zh_TW'); - expect(isLoaded('zh_TW')).toBe(true); + expect(isLoaded('zh-TW')).toBe(false); + await loadLanguageAsync('zh-TW'); + expect(isLoaded('zh-TW')).toBe(true); }) it('checks if watching translation works', async () => {