Search code examples
node.jsinternationalizationkoa

URL i18n in koajs


I'm doing maintenance on a Koa (with koa-scaffold) web application. My client asked me for i18n and I started using koa-i18n. I was using sub domains (en.example.com, es.example.com) but now my client decided he wants to use just the URL (www.example.com/en/hello/ and www.example.com/es/hola/).

What should I do to make the plug in work like this? Should I modify the controller? I'm pretty new to koajs.

Thanks


Solution

  • I hope this is not too late, but recently I added the ability to get locale from the URL in koa-locale.

    https://www.npmjs.com/package/koa-locale