Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements + updates ✨ #43

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

190 changes: 0 additions & 190 deletions .eslintrc

This file was deleted.

35 changes: 25 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
# OS #
###################
.DS_Store
.idea
Thumbs.db
tmp/
temp/


# Node.js #
###################
node_modules
package-lock.json


# NYC #
###################
coverage
*.lcov
.nyc_output


# Files #
###################
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

node_modules
npm-debug.log
coverage
.idea
*.gz
4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"reporter": "spec",
"timeout": 5000
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
12 changes: 12 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extension": [
".js"
],
"reporter": [
"text-lcov",
"text",
"lcov"
],
"report-dir": "./coverage",
"temp-dir": "./.nyc_output"
}
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
sudo: false
language: node_js
node_js:
- '4'
- '6'
- '8'
- '10'
- '12'
install:
- npm i npminstall && npminstall
- 8
- 10
- 12
- 14
script:
- npm run ci
after_script:
- npminstall codecov && codecov
- npm install codecov && codecov
5 changes: 0 additions & 5 deletions AUTHORS

This file was deleted.

6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This software is licensed under the MIT License.
(The MIT License)

Copyright (c) 2015 - 2017 koajs and other contributors
Copyright (c) 2015-present Koa.js and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
koa-locales
[koa-locales](https://github.com/koajs/locales)
=======

[![NPM version][npm-image]][npm-url]
Expand All @@ -14,19 +14,27 @@ koa locales, i18n solution for koa:
3. One api: `__(key[, value, ...])`.
4. Auto detect request locale from `query`, `cookie` and `header: Accept-Language`.

> This module is compatible with all Koa versions.

## Installation

```bash
$ npm install koa-locales --save
# npm ..
$ npm add koa-locales
# yarn ..
$ yarn add koa-locales
```

## Quick start

```js
const koa = require('koa');
const Koa = require('koa');
const locales = require('koa-locales');

const app = koa();
// [email protected]
// const app = Koa();
// [email protected]
const app = new Koa();
const options = {
dirs: [__dirname + '/locales', __dirname + '/foo/locales'],
};
Expand All @@ -39,16 +47,16 @@ locales(app, options);

Patch locales functions to koa app.

- {Application} app: koa app instance.
- {Object} options: optional params.
- {String} functionName: locale function name patch on koa context. Optional, default is `__`.
- {String} dirs: locales resources store directories. Optional, default is `['$PWD/locales']`.
- {String} defaultLocale: default locale. Optional, default is `en-US`.
- {String} queryField: locale field name on query. Optional, default is `locale`.
- {String} cookieField: locale field name on cookie. Optional, default is `locale`.
- {String} cookieDomain: domain on cookie. Optional, default is `''`.
- {Object} localeAlias: locale value map. Optional, default is `{}`.
- {String|Number} cookieMaxAge: set locale cookie value max age. Optional, default is `1y`, expired after one year.
- {Application} **app**: koa app instance.
- {Object} **options**: optional params.
- {String} **functionName**: locale function name patch on koa context. Optional, default is `__`.
- {String} **dirs**: locales resources store directories. Optional, default is `['$PWD/locales']`.
- {String} **defaultLocale**: default locale. Optional, default is `en-US`.
- {String} **queryField**: locale field name on query. Optional, default is `locale`.
- {String} **cookieField**: locale field name on cookie. Optional, default is `locale`.
- {String} **cookieDomain**: domain on cookie. Optional, default is `''`.
- {Object} **localeAlias**: locale value map. Optional, default is `{}`.
- {String|Number} **cookieMaxAge**: set locale cookie value max age. Optional, default is `1y`, expired after one year.

```js
locales({
Expand Down
18 changes: 0 additions & 18 deletions appveyor.yml

This file was deleted.

Loading