Open LasyIsLazy opened 2 years ago
Hi! I have the same error. When using a dot in the key - te
always returns false. Version ^9.2.0-beta.36
.
Same problem here. Please support it ( maybe just an option to choose the key separator)
Same for me.
same, had to remove $te check in the if before, was wondering why i18n didn't work after dependency update
when my key is Chinese,it can't match.
Same issue - using this workaround for now...
import _ from 'lodash';
i18n.global.te = (key, locale) => {
let effectiveLocale= !_.isEmpty(locale) ? locale : i18n.global.locale;
let messages = i18n.global.messages[effectiveLocale];
return Object.hasOwn(messages, key);
};
Still not fixed :(
@dmcknight26 solution works, some changes:
import { isEmpty } from 'lodash'
i18n.global.te = (key: string, locale: string) => {
const effectiveLocale = !isEmpty(locale) ? locale : i18n.global.locale.value
const messages = i18n.global.messages.value[effectiveLocale]
return Object.hasOwn(messages, key)
}
@dmcknight26 @MindaugasR
Thank you for your solution, here is the Typescript support (also without lodash dependency):
export const i18n = createI18n({
locale: `fr-FR`,
legacy: false,
warnHtmlMessage: false,
messages,
})
i18n.global.te = (key: Parameters<typeof i18n.global.te>[0], locale: Parameters<typeof i18n.global.te>[1]) => {
const effectiveLocale = locale && locale.length ? locale : i18n.global.locale.value
const messages = i18n.global.messages.value[effectiveLocale]
return Object.hasOwn(messages, key)
}
Bump, I'm using a flattened json for i18n,
For something like spotlight.title
, using t('spotlight.title')
works, but rt('@:spotlight.title')
doesn't, weirdly inconsistent.
Refs for attention: intlify/vue-i18n-next#271
Bump, I'm using a flattened json for i18n, For something like
spotlight.title
, usingt('spotlight.title')
works, butrt('@:spotlight.title')
doesn't, weirdly inconsistent.Refs for attention: intlify/vue-i18n#271
We are facing the same issue.
Reporting a bug?
If
key
has dot likea.b.c
,$t('a.b.c')
will get the correct result, but$te
will return false.Expected behavior
$te
returntrue
Reproduction
$t('a.b.c')
returnfalse
System Info
Screenshot
No response
Additional context
No response
Validations