Coder Social home page Coder Social logo

Comments (10)

jplhomer avatar jplhomer commented on July 17, 2024 4

Per Tobi:

We don’t need a local i18n system by template. That’s something people can add themselves via standard react tools. What we need is to be able to request Shopify data with the right locale settings so that the data from us comes in whatever people need. But “how do I add i18n” should be a tutorial, not a default ship.

from hydrogen-v1.

benjaminsehl avatar benjaminsehl commented on July 17, 2024 1

@jplhomer: Does the response from this differ from what you'd get from a query with inContext / LocalizationProvider?

Heads up that your link is relative so hits a 404. Should be: nextjs.org/docs/advanced-features/i18n-routing

And then to your point, there is one thing to predict the locale via browser settings and a fallback to GeoIP — another to provide a component to switch locale (like CurrencySwitcher) and persist via cookie or localStorage — and a third to set via URL/the router.

i18n, the Redirects ticket (#89) and the overall "dynamic" goal are all use cases that Next.js solved through their Middleware approach. Has this been discussed? I may just be missing something with Vite or RSC that covers this.

from hydrogen-v1.

jplhomer avatar jplhomer commented on July 17, 2024 1

Thanks to @bitforcesrl we have step one here: Shopify/hydrogen#397

Our documentation should give developers tips on how to leverage the new locale option in useShopQuery to make localized requests.

from hydrogen-v1.

jplhomer avatar jplhomer commented on July 17, 2024

A couple options here:

Decisions we need to make:

  • How opinionated do we make this?
  • Do we make it a part of the scaffold only, or abstracted away into the SDK?
  • We need to use something that is simple, works with Vite, and can be SSR without interaction from the developer.

from hydrogen-v1.

jplhomer avatar jplhomer commented on July 17, 2024

Thanks @benjaminsehl!

Next.js solved through their Middleware approach. Has this been discussed?

Not really! I still think there's room in Hydrogen framework for a hook or middleware interface. Not sure exactly where that lives or what it looks like yet.

from hydrogen-v1.

bitforcesrl avatar bitforcesrl commented on July 17, 2024

Hello, this is an hot topic!! To support i18n we need translated URL parts for good SEO. @jplhomer do you plan to do something in this area (hook or config) or do we have to find some workarounds (or force to use next framework)
many thanks

from hydrogen-v1.

jplhomer avatar jplhomer commented on July 17, 2024

Hmm we don't have any plans for localized routing parts right now. That's super intriguing, and I wonder what an API would look like? You couldn't use file-based routing, as it exists, because everything is translated, right?

from hydrogen-v1.

bitforcesrl avatar bitforcesrl commented on July 17, 2024

@jplhomer i've opened a PR here just to be able to retrieve translated content from storefront API
Shopify/hydrogen#397
this is just a start, very primitive, because the correct way would be set the locale in the useShop context, then it should be call a setServerState but not setting a props called locale (the same happen for country)
we should do setServerState('path', [...path, newLocale])
this should redirect the use to /it or /en and all server pages should be able to read that params as input to use it in the queries

the same for country so the final PW should be
setServerState('path', [...path, `${country}-'${locale}'])

then inside every server page something like this

export default function Collection({
 path
}) {
{country, locale, pagination, productFilters, sortKey, reverse} = helperFnToExtractFromThePath(path)

const {data} = useShopQuery({
    query: QUERY,
    variables: {
      handle,
      country,
      locale,
      numProducts: collectionProductCount,
      productFilters,
      sortKey,
      reverse,
    },
    cache: {
      maxAge: 90000,
    },
  });

from hydrogen-v1.

jplhomer avatar jplhomer commented on July 17, 2024

Dupe of Shopify/hydrogen#1173 - using that to track for now.

from hydrogen-v1.

patrick-schneider-latori avatar patrick-schneider-latori commented on July 17, 2024

Is there already some kind of basic idea how i18n routing can be solved with Hydrogen?

from hydrogen-v1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.