Skip to content

Commit

Permalink
Modernize project (#41)
Browse files Browse the repository at this point in the history
* chore: Make index.js a es6 module, add umd/cjs build scripts
* feat: Add `plurals.js` es6 module with named exports
* style: Convert main module to es6/es2015 syntax
* Pin dependencies
* Add dist files to repo
* Prettify code and cleanup
* Kick buble, if you want to support older browsers use buble in your build
* Adapt urls
* Test on modern node version
* Force parens for arrow functions
* Build only commonjs
  • Loading branch information
maranomynet authored and StephanHoyer committed Apr 26, 2018
1 parent d759808 commit 9892815
Show file tree
Hide file tree
Showing 14 changed files with 508 additions and 583 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
node_modules
npm-debug.log
yarn-error.log
.idea
.vscode
.DS_Store
common.js
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": false,
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"arrowParens": "always",
"trailingComma": "es5",
"semi": false
}
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
sudo: false
node_js:
- 5.2
- 4.1
- 8
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Usage:
------

```JavaScript
var translate = require('translate.js')
import translate from 'translate.js'
// var translate = require('translate.js')

var messages = {
translationKey: 'Translation value'
Expand Down Expand Up @@ -88,7 +89,8 @@ var messages = {

Then bind the translation function to something short:
```JavaScript
var translate = require('translate.js')
import translate from 'translate.js'
// var translate = require('translate.js')
var t = translate(messages)
```

Expand Down Expand Up @@ -174,12 +176,13 @@ t('sheep', 21) => '21 kind' // pluralize_IS(21) => 's'
t('sheep', 13) => 'Baaahd luck' // direct subkey hit
```

Translate.js comes with a predefined `pluralize` functions for [several languages](pluralize/). These can be required into your code as needed, like so:
Translate.js comes with a predefined `pluralize` functions for [several languages](plurals.js). These can be imported into your code as needed, like so:

```js
var pluralize_IS = require('translate.js/pluralize/is')
import { plural_IS } from 'translate.js/plurals'
// var plural_IS = require('translate.js/pluralize/is')
var t = translate( messages_IS, {
pluralize: pluralize_IS
pluralize: plural_IS
})
```

Expand Down
Loading

0 comments on commit 9892815

Please sign in to comment.