Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit 1883e97

Browse files
committed
Initial commit
0 parents  commit 1883e97

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules
8+
9+
# Optional npm cache directory
10+
.npm
11+
12+
# Optional REPL history
13+
.node_repl_history

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Clayton Watts
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# messageformat.js loader for webpack
2+
3+
## Dependencies
4+
5+
* Requires [messageformat.js](https://github.com/messageformat/messageformat.js) 1.0.0-rc.3 or higher
6+
7+
## Install
8+
9+
```
10+
npm install messageformat-loader
11+
```
12+
13+
## Usage
14+
15+
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
16+
17+
[Documentation: messageformat.js](https://messageformat.github.io/)
18+
19+
### messages.json
20+
21+
```json
22+
{
23+
"simple-example": "A simple message.",
24+
"var-example": "Message with {X}.",
25+
"plural-example": "You have {N, plural, =0{no messages} one{1 message} other{# messages}}.",
26+
"select-example": "{GENDER, select, male{He has} female{She has} other{They have}} sent you a message.",
27+
"ordinal-example": "The {N, selectordinal, one{1st} two{2nd} few{3rd} other{#th}} message."
28+
}
29+
```
30+
31+
### example.js
32+
33+
``` javascript
34+
var messages = require('messageformat!./messages.json');
35+
messages['ordinal-example']({ N: 1 });
36+
// => 'The 1st message.'
37+
```
38+
39+
## License
40+
41+
MIT

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var loaderUtils = require('loader-utils');
2+
var MessageFormat = require('messageformat');
3+
4+
module.exports = function(source) {
5+
var query = loaderUtils.parseQuery(this.query);
6+
var output = new MessageFormat(query.locale).compile(source).toString('module.exports');
7+
return output;
8+
};

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "messageformat-loader",
3+
"version": "0.1.0",
4+
"description": "Webpack loader for https://github.com/messageformat/messageformat.js",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/cletusw/messageformat-loader.git"
12+
},
13+
"keywords": [
14+
"i18n",
15+
"pluralformat",
16+
"icu",
17+
"gettext",
18+
"choiceformat",
19+
"selectformat",
20+
"messageformat",
21+
"internationalization",
22+
"webpack"
23+
],
24+
"author": "Clayton Watts <[email protected]> (https://github.com/cletusw)",
25+
"license": "MIT",
26+
"bugs": {
27+
"url": "https://github.com/cletusw/messageformat-loader/issues"
28+
},
29+
"homepage": "https://github.com/cletusw/messageformat-loader#readme",
30+
"peerDependencies": {
31+
"messageformat": "^1.0.0-rc.3"
32+
},
33+
"dependencies": {
34+
"loader-utils": "^0.2.15"
35+
}
36+
}

0 commit comments

Comments
 (0)