Skip to content

Commit c4c6af5

Browse files
committed
Initial Commit
Make react-message-source public
0 parents  commit c4c6af5

23 files changed

+21032
-0
lines changed

.babelrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
"plugins": [
3+
"@babel/plugin-proposal-class-properties"
4+
],
5+
"presets": [
6+
["@babel/preset-react"],
7+
[
8+
"@babel/preset-env", {
9+
"targets": {
10+
"ie": "11"
11+
}
12+
}
13+
]
14+
]
15+
};
16+

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
/dist
3+
rollup.config.js

.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"jest": true,
4+
"browser": true
5+
},
6+
"extends": [
7+
"airbnb",
8+
"prettier"
9+
],
10+
"plugins": [
11+
"prettier"
12+
],
13+
"parser": "babel-eslint",
14+
"rules": {
15+
"import/prefer-default-export": "off",
16+
"prettier/prettier": "error",
17+
"react/destructuring-assignment": "off",
18+
"react/jsx-filename-extension": "off",
19+
"react/jsx-one-expression-per-line": "off",
20+
"react/jsx-wrap-multilines": "off",
21+
"react/require-default-props": "off"
22+
}
23+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
.idea
3+
.vscode
4+
node_modules
5+
6+
dist

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parser": "flow",
3+
"bracketSpacing": true,
4+
"jsxBracketSameLine": false,
5+
"printWidth": 120,
6+
"semi": true,
7+
"singleQuote": true,
8+
"tabWidth": 2,
9+
"trailingComma": "all",
10+
"useTabs": false
11+
}

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# react-message-source
2+
3+
> A library which aids with I18n of React applications
4+
5+
[![NPM](https://img.shields.io/npm/v/react-message-source.svg)](https://www.npmjs.com/package/react-message-source) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
6+
7+
## Install
8+
9+
```bash
10+
npm install --save react-message-source
11+
or
12+
yarn add react-message-source
13+
```
14+
15+
## Usage
16+
17+
```jsx
18+
// in MyComponent.jsx
19+
import React from 'react'
20+
import { withMessages } from 'react-message-source'
21+
22+
function MyComponent(props) {
23+
const { getMessage } = props;
24+
return <span>{getMessage('hello.world')}</span>
25+
}
26+
27+
export default withMessages(MyComponent)
28+
```
29+
30+
```jsx
31+
// in App.jsx
32+
import React, { Component } from 'react'
33+
34+
import * as MessageSource from 'react-message-source'
35+
import translations from './translations.json'
36+
37+
import MyComponent from './MyComponent'
38+
39+
class App extends Component {
40+
render () {
41+
return (
42+
<MessageSource.Provider value={translations}>
43+
<MyComponent />
44+
</MessageSource.Provider>
45+
)
46+
}
47+
}
48+
```
49+
50+
## License
51+
52+
MIT © [](https://github.com/)

example/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PORT=9009

example/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "react-message-source-example",
3+
"homepage": "https://.github.io/react-message-source",
4+
"version": "0.0.0",
5+
"license": "MIT",
6+
"private": true,
7+
"dependencies": {
8+
"prop-types": "^15.7.1",
9+
"react": "^16.8.1",
10+
"react-dom": "^16.8.1",
11+
"react-message-source": "link:..",
12+
"react-scripts": "2.1.5"
13+
},
14+
"scripts": {
15+
"start": "react-scripts start",
16+
"build": "react-scripts build",
17+
"test": "react-scripts test --env=jsdom",
18+
"eject": "react-scripts eject"
19+
},
20+
"browserslist": [
21+
">0.2%",
22+
"not dead",
23+
"not ie <= 11",
24+
"not op_mini all"
25+
]
26+
}

example/public/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<meta name="theme-color" content="#000000">
7+
8+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
9+
10+
<title>react-message-source</title>
11+
</head>
12+
13+
<body>
14+
<noscript>
15+
You need to enable JavaScript to run this app.
16+
</noscript>
17+
18+
<div id="root"></div>
19+
</body>
20+
</html>

example/public/manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"short_name": "react-message-source",
3+
"name": "react-message-source",
4+
"start_url": "./index.html",
5+
"display": "standalone",
6+
"theme_color": "#000000",
7+
"background_color": "#ffffff"
8+
}

0 commit comments

Comments
 (0)