Skip to content

i18n Support #16

Open
Open
@rylanharper

Description

@rylanharper

This feature was first proposed in this discussion last year.

⚡️ Summary

We should add multilingual support for Nitrogen using the Nuxt i18n module. However, there are some considerations regarding implementation and the components/files that need modifications..

For reference, Hydrogen outlines a localization strategy in its "Markets" documentation. Hydrogen seem to provide some utility functions and helpers to help with the following:

  1. Adjust store localization dynamically (both language and currency codes).
  2. Modify the URL to reflect the selected language/country.

We might take a different approach with Nitrogen. Instead of manually defining data helpers with additional utils, we could explore whether the Nuxt i18n module can pull dynamic locale data from our existing localization query. This query already provides availableLanguages and availableCountries based on the storefront’s Markets settings.

Warning

I’m unsure if Nuxt i18n supports dynamic localization data at runtime (or at any time haha). If not, we may still need a countries.ts helper or additional utilities functions to integrate this.

🛠️ Implementation

A general implementation of this feature would look like this:

  1. Dynamic Locale Handling

    • Investigate if Nuxt i18n can accept dynamic locale data from the localization query.
    • This data would then be passed to the shop.ts store. (Currently, there’s a locale.language state, but it isn’t being used yet.)
  2. Updating the Locale Modal

    • Modify the locale modal component to include an additional language selection dropdown after the existing country selector.
    • When a user saves their selection, both store country locale and language should update in the store.
  3. URL Localization (To Be Determined)

    • Ideally, the URL should reflect the selected language, similar to Hydrogen: hydrogen.shop/fr/my-route
    • However, we need to test how this interacts with existing route parameters (e.g., collection filters, product variants, pagination, etc.).

@alefbarbeli Any thoughts on this approach? Also, if you’ve worked with Nuxt i18n before, do you know if it supports dynamic locale configuration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions