Giter VIP home page Giter VIP logo

Comments (6)

QuiiBz avatar QuiiBz commented on July 29, 2024

This is currently not possible: next-international will try to use the user's defined locale if it has been configured in createI18n, or fallback if none has been found. What's the reason you don't want users to have their preferred locale?

from next-international.

sikandarchishty avatar sikandarchishty commented on July 29, 2024

Particularly in current use case I want a default language despite user's locale and then ability to change accordingly if they want.

What's the order of check list? is this the one?

  1. User detected locale
  2. User defined locale
  3. fallback

if yes, is there a possibility to change this order and override everything to use jsut user-defined?

Thanks.

from next-international.

QuiiBz avatar QuiiBz commented on July 29, 2024

I'm assuming you are using the App Router, so the order is:

  • Extract the user's locale from the Accept-Language header
  • If the header isn't found, use the default locale
  • If the locale has been defined in the array of createI18nMiddleware, use it
  • Else, use the default locale

The default locale is the one defined as a second argument in createI18nMiddleware. It's currently not possible to force the default locale, but we could add an option if necessary.

from next-international.

sikandarchishty avatar sikandarchishty commented on July 29, 2024

It would be great to add this override functionality, I have encountered this problem with every package and couldn't find the solution to this.
Is there a quicker fix that I can do on my own or wait for next release?

Thanks a ton.

from next-international.

QuiiBz avatar QuiiBz commented on July 29, 2024

This is somehow related to #96 as both issues could be solved with the same solution (= having a new option to return the locale from a request)

from next-international.

QuiiBz avatar QuiiBz commented on July 29, 2024

I've released 0.9.0 which includes a new resolveLocaleFromRequest option inside createI18nMiddleware, where you can add your own locale resolution logic.

Feel free to open another issue if you're not able to make it work.

from next-international.

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.