Open VirtualZer0 opened 1 year ago
Thank you for your reporting!
That regression is occured from v8.0.0-beta.10, when I confirmed with your reproduction by changing package.json
This issue is caused by unplugin-vue-i18n, so we need fix it.
I face the same problem ! It's realy nice to see that the error is report ! Thx for you incredible work on that module 💚 !
It also doesn't work in <i18n>
blocks in SFC's
We usually split our app in multiple module instead of having one single big localization file.
global, errors, etc...
. I hope this get fixed soon.
Hi! Any idea when this is going to be fixed / what needs to be done?
Currently, since the <i18n>
blocks in SFC don't work, it's painful to translate many pages, as there is only one global file.
I dug into the code of unplugin-vue-i18n
to try and find the issue, I failed so far.
However, I've found that this line gives off 'i18n'
as the langInfo
, when no lang
attribute is provided. This variable is used a few lines below to determine if we should use generateJSON
or generateYAML
. Therefore, by default, generateYAML
is used by default regardless of defaultSFCLang
. This can be fixed by setting explicitly an attribute in the i18n
tag (<i18n lang="json">
).
However, it still does not work. @kazupon do you have an idea of what does not work in unplugin-vue-i18n
? Is there an issue open in that repo? Why do the e2e tests of unplugin-vue-i18n
don't have the same issue?
I have a workaround using the edge version for import files, I have changed you reproduction here to demonstrate.
By using defineI18nLocale
with a function it works like so:
import submodule from './submodule';
export default defineI18nLocale(() => ({
submodule,
simpleString: 'Working',
}));
Note the config in the edited reproduction has cache for the locale file enabled, this is disabled for dynamic/function locale files by default. Not required to get it to work, but worth mentioning as the example is essentially static.
Environment
Reproduction
https://stackblitz.com/edit/github-ebdazc?file=app.vue
Describe the bug
Some time ago I started a project with a localization structure, where the localization was splitted into several files and imported into the index file, and it worked. Today I found that it stopped working. The console shows messages that the specified keys are not found, only the strings specified in the main file directly, without importing, work.
Additional context
File structure example:
Where
index.ts
isand
submodule.ts
isnuxt.config.ts
:Logs