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

Falllback locale not working when the key path is not incomplete exist in current locale data #2644

Closed
everyx opened this issue Dec 31, 2023 · 2 comments

Comments

@everyx
Copy link

everyx commented Dec 31, 2023

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.2
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, i18n
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-dwhr3q?file=pages%2Findex.vue

Describe the bug

When I set default en locale message as below:

{
	"deep": {
		"hello": {
			"world": "Test"
		}
	}
}

and another es locale message as below:

{
	"deep": {
		"hello":  null
	}
}

I use tm and rt to get and display this message

<script lang="ts" setup>
const { tm, rt } = useI18n({ useScope: 'global' });
const test = tm('deep.hello.world');
</script>
<template>
  <div>
    <h1>Nuxt I18n Starter - {{ $t('hello') }}!</h1>
    <p>{{ rt(test) }}</p>
  </div>
</template>

Then if I switch locale from en to es, I get error last is null and can not fallback to 'en' message.

I also tried vue-i18n and there was no such problem. For an example, see https://stackblitz.com/edit/vitejs-vite-asteuw?file=src%2FApp.vue

Additional context

No response

Logs

No response

@BobbieGoede
Copy link
Collaborator

This doesn't work in vue-i18n either, it seems like your vue-i18n reproduction silently fails. If you set the locale to 'ja' and the fallbackLocale to 'en' it will error on load. I have edited your reproduction to demonstrate here, if you expect this behavior to work I suggest opening an issue on repo of vue-i18n.

@everyx
Copy link
Author

everyx commented Jan 17, 2024

@BobbieGoede just created a issue in upstream, thanks intlify/vue-i18n#1702

@everyx everyx closed this as completed Jan 17, 2024
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