koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.
MIT License
871 stars 176 forks source link

Localized routes #89

Closed Dronar closed 3 years ago

Dronar commented 4 years ago

Hi!

I recently encountered a task where I needed my routes to be localized for different languages. I also wanted a localized route only to be active for that language, i.e responding with a 404 if that route did not belong to that language.

I posted a question on StackOverflow which I then managed to solve myself: https://stackoverflow.com/questions/62081482/localized-routes-in-koa/

I am not sure if this is something that should be included in this package and if this is the best solution but it is a functionality that I missed and I suspect others might run into it as well.

If this is indeed something that should be included in this package maybe someone could coach me to write a proper pull request for such feature? :)

talentlessguy commented 3 years ago

Hey, I know it's a bit of late but there's i18-next-http-middleware that can be used with Koa as well (and any other Node.js web framework)

niftylettuce commented 3 years ago

I wouldn't use that, we have this built into @ladjs, see @ladjs/i18n at https://github.com/ladjs/i18n