question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Koa is a new framework using ES6 generator, by the creators of Express. There is however a small change in the api of middleware compared to Express. Instead of having Request and Responses objects, they’re using the this object, with similar data on the object. So the i18n.init middleware won’t work.

I wanted to write my own middleware, however the guessLanguage & applyAPItoObject functions are private, so it’s rather difficult. I was wondering if Koa support is planned, or if maybe both those functions could be exposed so that I could write some middleware for Koa.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
niftylettucecommented, Oct 6, 2016

For anyone interested, @crocodilejs uses this package in the framework (which is Koa@next + ES7) https://github.com/crocodilejs/crocodile-node-mvc-framework, but written with some cool glue on top. I didn’t want to fork this because there are so many other i18n packages out there to confuse people with. But maybe I should?

Here’s the code for anyone interested:

https://github.com/crocodilejs/crocodile-node-mvc-framework/blob/294407e84a0d9c4377d0f9fe237b2a7278c6a028/src/helpers/i18n.js

Basically you do app.use(i18n.middleware); first, and then follow it with app.use(i18n.redirect); second. The latter is for locale support in URL’s though (it redirects from / to /en by default, or if you have /foo/bar it will redirect to the locale /en/foo/bar for example. CrocodileJS is set up for you automatically to handle this.

If anyone ends up looking into this, I recommend you join us in Slack for more discussion and insight into what we’re doing with CrocodileJS! http://slack.crocodilejs.com

Some screenshots of what we’re doing using this package below…

screen shot 2016-10-06 at 12 34 54 am screen shot 2016-10-06 at 12 33 37 am screen shot 2016-10-06 at 12 33 33 am

cc @mashpie 👍 thank you for making this ❤️ ✨ 🦄

0reactions
mashpiecommented, May 25, 2021

😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contact KOA | KOA FAQ | Frequently Asked Questions
Contact the KOA Corporate Office. Contact Us Online. Customer Service: 1-888-562-0000. Please note: KOA Campgrounds are franchised and handle all of the day ......
Read more >
Do I receive a card? - KOA
Help : Frequently Asked Questions. Do I receive a card? KOA Campgrounds do not need a printed copy of your account. All KOAs ......
Read more >
Camping Loyalty Program & Discounts With KOA Rewards
So no more searching for the best RV campground membership or loyalty program, purchase or renew rewards with KOA today and start earning...
Read more >
KOA Care Camps Trust | Helping Kids With Cancer
KOA Care Camps is the official charity of the KOA Owners Association and offers camping experiences for children battling cancer. Learn more today....
Read more >
Feedback - KOA
We use cookies on koa.com to help improve your experience by remembering your preferences and repeat visits, troubleshoot how the site operates, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found