alp-translate
Translation in alp framework
Config
config/locales/en.yml
common:
'Hello %s!': 'Hello %s!'
With Koa
import Koa from 'koa';
import config from 'alp-node-config';
import translate from 'alp-translate';
const app = new Koa();
config(new URL('./config', import.meta.url))(app);
translate('locales')(app);
index(ctx) {
const name = ctx.params.string('name').notEmpty().value;
ctx.body = ctx.t('Hello %s!', ctx.params.isValid() ? name : 'World');
},