nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

$i18n.locales only returns code and not other properties #2766

Closed bsiguret closed 9 months ago

bsiguret commented 9 months ago

Environment

Reproduction

See additional context for actual results

You can reproduce with the latest version and before 8.0.0-rc.6 to highlight the differences.

Describe the bug

Hello, it's basically what's said in this discussion: https://github.com/nuxt-modules/i18n/discussions/2619#discussion-5958789

I'm in the same position, more or less. I put custom keys in my i18n locales config to access it in my switch languages component. The problem is since 8.0.00-rc.6, $i18n.locales isn't returning the whole locales config but only the locales code (like availableLocales).

I'm not finding new composable or property to have the same old comportment. I only found localeProperties but only for the current locale, which is not what I need. Is this change intended, since I'm not finding anything in the changelog? If yes, I'll just put this config in runtimeConfig to be able to access it and refactor my component.

I'm just highlighting this comportment change just in case, sorry if you find it unnecessary 😄

Thank you for your time.

Additional context

Before: console.log($i18n.locales)

[
    {
        "code": "fr",
        "iso": "fr-FR",
        "dateFormat": "dd/MM/yyyy",
        "iconComponent": "IFrenchFlag",
        "emoji": "🇫🇷",
        "switchText": "Français",
        "files": [
            "lang/fr-FR.json",
            "lang/fr-FR/flash.json",
            "lang/fr-FR/errors.json"
        ]
    },
    {
        "code": "en",
        "iso": "en-GB",
        "iconComponent": "IEnglishFlag",
        "dateFormat": "MM/dd/yyyy",
        "emoji": "🇬🇧",
        "switchText": "English",
        "files": [
            "lang/en-GB.json",
            "lang/en-GB/flash.json",
            "lang/en-GB/errors.json"
        ]
    },
    {
        "code": "pt-BR",
        "iso": "pt-BR",
        "iconComponent": "IBrazilFlag",
        "dateFormat": "dd/MM/yyyy",
        "emoji": "🇧🇷",
        "switchText": "Português",
        "files": [
            "lang/pt-BR.json",
            "lang/pt-BR/flash.json",
            "lang/pt-BR/errors.json"
        ]
    }
]

After: console.log($i18n.locales)

[
    "fr",
    "en",
    "pt-BR"
]

Logs

No response

github-actions[bot] commented 9 months ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 [Reproduction starter (v8 and higher)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/v8) 👉 [Reproduction starter (edge)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/edge) A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
BobbieGoede commented 9 months ago

I'm unable to replicate this using the latest release, are you sure you experience this after installing the latest version? If so, could you add a minimal reproduction?

bsiguret commented 9 months ago

Yes, I tried to update from rc5 to the latest version. Then I had several bugs and tried to do it step by step with newer rc versions.

But strangely, I can't reproduce it with the stackblitz you provide. I'll dig further into my app and come back to you. It's a real prod app with a lot of things going on, so it may be tricky to catch. Sadly I can't share the repo for obvious reasons.

I'll close this if I can't give you further indications. I should have tested with the stackblitz before opening the issue, sorry for that.