This repository was archived by the owner on Mar 4, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 "/>
5+ < title > Getting Started</ title >
6+ </ head >
7+ < body >
8+ < script src ="bundle.js "> </ script >
9+ </ body >
10+ </ html >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " messageformat-yaml-loader-example" ,
3+ "version" : " 0.1.0" ,
4+ "description" : " Minimal example for messageformat-yaml-loader" ,
5+ "scripts" : {
6+ "build" : " webpack" ,
7+ "prepare" : " npm run build"
8+ },
9+ "main" : " src/index.js" ,
10+ "repository" : " https://github.com/eemeli/messageformat-yaml-loader" ,
11+ "author" : " Eemeli Aro <eemeli@gmail.com>" ,
12+ "license" : " MIT" ,
13+ "dependencies" : {
14+ "messageformat-yaml-loader" : " file:../" ,
15+ "webpack" : " ^3.8.1"
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ import messages from './messages.yml'
2+ const { format, messages : errors } = messages . en . errors
3+
4+ function component ( ) {
5+ const element = document . createElement ( 'div' )
6+ element . innerHTML = format ( {
7+ attribute : 'Your message' ,
8+ message : errors . wrong_length ( { count : 42 } )
9+ } )
10+ return element
11+ }
12+
13+ console . log ( 'messages' , messages )
14+ document . body . appendChild ( component ( ) )
Original file line number Diff line number Diff line change 1+ en :
2+ errors :
3+ format : " %{attribute} %{message}"
4+ messages :
5+ confirmation : " doesn't match %{attribute}"
6+ accepted : " must be accepted"
7+ wrong_length :
8+ one : " is the wrong length (should be 1 character)"
9+ other : " is the wrong length (should be %{count} characters)"
10+ equal_to : " must be equal to %{count}"
Original file line number Diff line number Diff line change 1+ const path = require ( 'path' )
2+
3+ module . exports = {
4+ entry : './src/index.js' ,
5+ output : {
6+ filename : 'bundle.js' ,
7+ path : path . resolve ( __dirname , 'dist' )
8+ } ,
9+ module : {
10+ rules : [
11+ {
12+ test : [ / \. y a m l $ / , / \. y m l $ / ] ,
13+ loader : require . resolve ( 'messageformat-yaml-loader' ) ,
14+ options : {
15+ biDiSupport : false ,
16+ defaultLocale : 'en' ,
17+ includeLocales : null ,
18+ pluralVariable : 'count' ,
19+ verbose : false
20+ }
21+ }
22+ ]
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments