Skip to content

Update i18n example test to actually exercise vuei18n#673

Closed
sarayourfriend wants to merge 3 commits intonuxt:mainfrom
sarayourfriend:add/reproduce-i18n-issue
Closed

Update i18n example test to actually exercise vuei18n#673
sarayourfriend wants to merge 3 commits intonuxt:mainfrom
sarayourfriend:add/reproduce-i18n-issue

Conversation

@sarayourfriend
Copy link
Copy Markdown

This shows a minimal reproduction of the issue discussed in #585

Hi from @nuxtjs/i18n: {{ (('hello')) }}
Hi from @nuxtjs/i18n: {{ $t('hello') }}
</div>
<div>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div>
<i18n-t scope="global" keypath="message"><template #module>@nuxtjs/i18n</template></i18n-t>
<div>

The error in i18n can be fixed by importing i18n from useNuxtApp().$i18n. However, I couldn't find a way to fix the i18n-t component. I tried replacing it with the Translation component imported from vue-i18n, but the error persists.

This suggested change will also need an addition to the i18n messages:
"message": "Hello from {module}"

@danielroe danielroe mentioned this pull request Dec 25, 2023
8 tasks
@danielroe
Copy link
Copy Markdown
Member

As far as I can tell the issue here is because the @nuxtjs/i18n module is calling vueApp.use on the CJS version of vue-i18n, but when we use useI18n in the test, it's the ESM version of the library, and so it thinks it's not registered.

Without looking further (though of course I will) I'm not sure whether this is something that @nuxt/test-utils should solve or whether it's an upstream issue ....

cc: @BobbieGoede so you're aware

@sarayourfriend
Copy link
Copy Markdown
Author

Thanks for figuring that out! Indeed, that doesn't seem like something this library should fix. @obulat I wonder if we can force Openverse (or at least the test suite) to use the CJS version?

@obulat
Copy link
Copy Markdown

obulat commented Dec 26, 2023

I opened an issue with the reproductions (using composable and i18n-t component) in the @nuxt-modules/i18n repository.
@sarayourfriend, I tried to find a way to hot-fix this issue, but I couldn't.
@danielroe, thank you for investigating this issue. Do you have any suggestions for hot-fixing this until the solution is found?

@danielroe
Copy link
Copy Markdown
Member

I still plan to investigate this further.

@indiehjaerta
Copy link
Copy Markdown

Any updates on the investigation of this? As it stands now this problem stops us from upgrading to the @nuxt/test-utils from nuxt-vitest that we have used before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants