Skip to content

Commit

Permalink
Minor update wording
Browse files Browse the repository at this point in the history
Update README.md

Update README.md
  • Loading branch information
Kun Ran authored and rankun203 committed Apr 13, 2017
1 parent f88c9ba commit b632819
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# koa-i18n

> I18n fro koa, based on [i18n-2].
> **NOTE**: If want to use koa-i18n, [koa-locale] must be required!
>
> **NOTE**: You must require('[koa-locale]') to make it detect locale info from headers, queries etc.
[![NPM version][npm-img]][npm-url]
[![Build status][travis-img]][travis-url]
Expand Down Expand Up @@ -31,14 +32,15 @@ const i18n = require('koa-i18n')

const app = new Koa()

// Required!
locale(app)

app.context.render = render({
root: __dirname + '/views/',
ext: 'html'
})

// First, load koa-locale into the app
locale(app)

// Then config koa-i18n
app.use(i18n(app, {
directory: './config/locales',
locales: ['zh-CN', 'en'], // `zh-CN` defualtLocale, must match the locales to the filenames
Expand All @@ -53,6 +55,7 @@ app.use(i18n(app, {
]
}))

// And use it with ctx.i18n.__('KEY');
app.use(function (ctx) {
ctx.body = ctx.i18n.__('any key');
})
Expand All @@ -63,7 +66,8 @@ app.use(convert(function *() {
```

> **Tip**: We can change position of the elements in the `modes` array.
> If one mode is detected, no continue to detect.
>
> If the client locale info is matched in one mode, the middleware will stop detecting and take that value.

### Dependencies
Expand Down

0 comments on commit b632819

Please sign in to comment.