Open MartinRamm opened 3 years ago
Thank you for your reporting!
sorry, I could not understand what issue your registered. I think this behavior is correct…
Could you give us a more detailed explanation of what the issue is, please? 🙏
Sure, @kazupon.
Let me give you some context to the problem: generally, there are two ways to work with key-based translation systems:
home.welcome_message
). This description becomes the key, which gets mapped to the actual translation (e.g. Hello, World!
) via your app.Hello, World!
, you write in your code $t('Hello, World!')
. This bug report is about the second approach. There are multiple pro and cons for each approach, I won't go into them too much, but in the second approach, you trade context (knowing where the text will be displayed exactly) with knowledge about the intended size of the text, the variables available, ease of development (you see what the end-user sees, can search the code for text the end-user sees), etc.
Probably I should have abstracted the bug-report more. Let me try again:
To Reproduce
json
file of the chosen locale
<i18n path="welcome_message" tag="p">
<template v-slot:world>
<b>World</b>
</template>
</i18n>
Hello, {world}!
const i18n = new VueI18n({
//....
missing: (locale, key) => 'Hello, {world}!',
});
Expected behavior The variable {world} is replaced with World in the HTML rendered output.
Actual behavior
The variable is not replaced. The HTML output shows Hello, {world}!
Module versions (please complete the following information):
vue
: 2.6.12vue-i18n
: 8.24.4Reproduction Link https://codesandbox.io/embed/optimistic-fast-rzgrd?&theme=dark If you add a translation (line 11 in
main.js
), it works as expected.To Reproduce
Hello, {world}!
) with a slot:Expected behavior The variable
{world}
is replaced with<b>World</b>
in the HTML rendered output, as ifmessages
(in the vue-i18n config) was set to:Actual behavior The variable is not replaced. The output shows the raw key:
Hello, {world}!
If I add a translation for the missing key (as shown above), it works.