Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading does not work with translations in single file components #3263

Closed
PaulCombal opened this issue Dec 12, 2024 · 1 comment
Closed

Comments

@PaulCombal
Copy link

Environment

Reproduction

Using single file component translations like so:

<script setup lang="ts">
const { t } = useI18n()
</script>

<template>
  <p>{{ t('hello') }}</p>
</template>

<i18n lang="json">
{
  "en": {
    "hello": "hello world!"
  },
  "ja": {
    "hello": "こんにちは、世界!"
  }
}
</i18n>

Lazy loading does not work: it seems to lazy load the translation files just fine but not the SFC translations.

Is this intended?

Describe the bug

I expected the language/translation chunks from SFCs to be downloaded on language switch, however only the language files seem to be downloaded.

Additional context

No response

Logs

@BobbieGoede
Copy link
Collaborator

The lazy loading feature only applies to locale files configured in nuxt.config with the i18n.locales.*.files entry.

The i18n blocks are handled at build/bundle by @intlify/unplugin-vue-i18n, I'm not entirely sure but I assume these translations are simply loaded with the component itself, I suggest opening an issue on that repo on adding lazy/separate loaded locale specific translations from i18n block.

Closing this as the feature does not cover this (so it is not a bug), and the behavior for i18n blocks is provided upstream.

@BobbieGoede BobbieGoede closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants