sergiodxa / remix-i18next

The easiest way to translate your Remix apps
https://sergiodxa.github.io/remix-i18next/
MIT License
618 stars 44 forks source link

Added language detection using path parameters #172

Closed OutOfBoundCats closed 10 months ago

OutOfBoundCats commented 10 months ago

As per my understanding of this article https://developers.google.com/search/docs/specialty/international/localized-versions Google recommends having lang as part of url. This aids in good seo. So i added language detection using path parameters as option to the repository.

sergiodxa commented 10 months ago

Thanks for the PR.

If you want to detect it from the param you can use Remix params object directly instead of using the language detection features of remix-i18next:

// app/routes/($lng)._index.tsx
export async function loader({ request, params }: LoaderFunctionArgs) {
  let lng = params.lng ?? fallbackLanguage;
  let t = await i18n.getFixedT(lng);
  // use t here
}

This is the recommended way since Remix already gives you a way to deal with params in the URL.