Skip to content
This repository has been archived by the owner on Feb 17, 2019. It is now read-only.

alpjs/alp-translate

Repository files navigation

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-config';
import translate from 'alp-translate';

const app = new Koa();
config(__dirname + '/config')(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');
    },

.t(key, ...args)