Git Product home page Git Product logo

Comments (7)

deitch avatar deitch commented on August 26, 2024

Hey @uvworkspace actually that is perfect. Years ago I did an i18n library for JS - at https://github.com/deitch/jsorm-i18n now a little dated - but the structure was the same. The concept is exactly that, you should be able to use files that end in en_US, else en else just the name. It was the inspiration for this part.

The only place in activator that the default language is used explicitly is those two lines in activator.js where it calls "en_US". It makes a lot of sense to do what you did - take it out to a config var, defaulting to "en_US" (which, I will admit, is a little America-centric, and I speak 3 languages and a smattering of a few others, but it is where most of the market is nowadays; just being practical).

The only question I have is whether or not req.lang is the right place to put it. It seems to have some common accepted practice, though, so we can live with it.

We definitely do not want to start parsing the Accept-Language header; that is something that should happen at earlier middleware, select the preferred language, and pass it on to activator.

Thanks for the great suggestions; we'll set up some tests and implement!

from activator.

deitch avatar deitch commented on August 26, 2024

Done. v0.4.4. Git push and npm publish complete. Enjoy!

from activator.

uvworkspace avatar uvworkspace commented on August 26, 2024

Well thanks a lot. I proposed so I don't have to clone it and modify just several lines. :).

from activator.

deitch avatar deitch commented on August 26, 2024

Actually was harder than I expected. The tests took some time to get just right, and although the req.lang || 'en_US was easy, there was a nasty little bug with the template caching. But all is great now.

from activator.

uvworkspace avatar uvworkspace commented on August 26, 2024

Yes I can see it now. I need to control the locale used for different user based on url query and/or session, so the locale assignment is done earlier, and using Accept-Language header is not enough for me.

Now I guess later someone who want to use it may ask to use a different property name, then allowing user to configure it in init() may be good enough for a longer while, I guess. Thanks for the hard work.

from activator.

deitch avatar deitch commented on August 26, 2024

So? Go ahead and put in middleware to set req.lang based on however you want. A different user can use different middleware.

Look in the README; I put in a very basic example of where and how to put it.

from activator.

deitch avatar deitch commented on August 26, 2024

And you are quite welcome! Use it well.

from activator.

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.