diff --git a/src/components/App.js b/src/components/App.js
index f357b24..228dd59 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -13,6 +13,10 @@ class App extends Component {
user: PropTypes.string
}
+ static contextTypes = {
+ dictionary: PropTypes.object
+ }
+
state = {
username: 'Roma'
}
@@ -27,25 +31,26 @@ class App extends Component {
render() {
console.log('---', 1)
+ const { dictionary } = this.context
return (
diff --git a/src/components/Menu/index.js b/src/components/Menu/index.js
index 096e674..52bbd70 100644
--- a/src/components/Menu/index.js
+++ b/src/components/Menu/index.js
@@ -7,10 +7,14 @@ class Menu extends Component {
};
+ static contextTypes = {
+ dictionary: PropTypes.object
+ }
+
render() {
return (
-
Main menu:
+ {this.context.dictionary.Main_menu}:
{this.props.children}
)
diff --git a/src/components/Root.js b/src/components/Root.js
new file mode 100644
index 0000000..2f566c8
--- /dev/null
+++ b/src/components/Root.js
@@ -0,0 +1,26 @@
+import React, { Component } from 'react'
+import PropTypes from 'prop-types'
+import App from './App'
+import dictionary from '../dictionary'
+
+class Root extends Component {
+ static childContextTypes = {
+ dictionary: PropTypes.object
+ }
+
+ getChildContext() {
+ return {
+ dictionary
+ }
+ }
+
+ render() {
+ return (
+
+ )
+ }
+}
+
+export default Root
\ No newline at end of file
diff --git a/src/components/UserForm.js b/src/components/UserForm.js
index 9a96e38..c99ae25 100644
--- a/src/components/UserForm.js
+++ b/src/components/UserForm.js
@@ -1,9 +1,14 @@
import React, { Component } from 'react'
+import PropTypes from 'prop-types'
class UserForm extends Component {
static propTypes = {
- };
+ }
+
+ static contextTypes = {
+ dictionary: PropTypes.object
+ }
state = {
user: ''
@@ -13,7 +18,7 @@ class UserForm extends Component {
const {value} = this.props
return (
- Username:
+ {this.context.dictionary.Username}:
)
}
diff --git a/src/components/common/Loader.js b/src/components/common/Loader.js
index 7577062..3bd2bdc 100644
--- a/src/components/common/Loader.js
+++ b/src/components/common/Loader.js
@@ -1,13 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
-function Loader(props) {
+function Loader(props, {dictionary}) {
return (
-
Loading...
+
{dictionary.Loading}...
)
}
Loader.propTypes = {
}
+Loader.contextTypes = {
+ dictionary: PropTypes.object
+}
+
export default Loader
\ No newline at end of file
diff --git a/src/components/routes/ArticleList.js b/src/components/routes/ArticleList.js
index 3cceedd..03111db 100644
--- a/src/components/routes/ArticleList.js
+++ b/src/components/routes/ArticleList.js
@@ -2,17 +2,22 @@ import React, { Component } from 'react'
import ArticleList from '../ArticleList'
import Article from '../Article'
import {Route} from 'react-router-dom'
+import PropTypes from 'prop-types'
class ArticleListPage extends Component {
static propTypes = {
- };
+ }
+
+ static contextTypes = {
+ dictionary: PropTypes.object
+ }
render() {
console.log('---', 2)
return (
-
Article list:
+
{this.context.dictionary.Article_list}:
@@ -20,7 +25,7 @@ class ArticleListPage extends Component {
}
getArticle = ({ match }) => {
- if (!match) return
Please select an article
+ if (!match) return
{this.context.dictionary.Please_select_an_article}
console.log('---', 3)
return
}
diff --git a/src/dictionary.js b/src/dictionary.js
new file mode 100644
index 0000000..7d0f4d4
--- /dev/null
+++ b/src/dictionary.js
@@ -0,0 +1,23 @@
+export default {
+ 'App_name': 'Название приложения',
+ 'Articles': 'Статьи',
+ 'Filters': 'Фильтры',
+ 'Counter': 'Счетчик',
+ 'Comments': 'Комментарии',
+ 'Add_new_Article_form': 'Добавить новую статью',
+ 'Error_page': 'Ошбика',
+ 'Nor_found': 'Не найдено',
+ 'Main_menu': 'Главное меню',
+ 'Username': 'Имя пользователя',
+ 'No_Articles': 'Нет статей',
+ 'Article_list': 'Список статей',
+ 'Please_select_an_article': 'Пожалуйста, выберите статью',
+ 'Loading': 'Загрузка',
+ 'User': 'Пользователь',
+ 'No_comments_yet': 'Пока нет комментариев',
+ 'hide_comments': 'скрыть комментарии',
+ 'show_comments': 'показать комметарии',
+ 'close': 'закрыть',
+ 'open': 'открыть',
+ 'delete': 'удалить'
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 8615453..c72acb5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,14 +1,16 @@
import React from 'react'
import {render} from 'react-dom'
import {Provider} from 'react-redux'
-import App from './components/App'
+import Root from './components/Root'
import {ConnectedRouter} from 'react-router-redux'
//import {HashRouter, BrowserRouter} from 'react-router-dom'
import store from './store'
import history from './history'
+
+
render(
-
+
, document.getElementById('container'))
\ No newline at end of file
diff --git a/src/reducer/articles.js b/src/reducer/articles.js
index ebde012..b8d1735 100644
--- a/src/reducer/articles.js
+++ b/src/reducer/articles.js
@@ -48,7 +48,11 @@ export default (articles = new ReducerRecord(), action) => {
return articles
.set('loading', false)
.set('loaded', true)
- .set('entities', arrToMap(response, ArticleRecord))
+ .update('entities', (entitiesValue) => {
+ return entitiesValue.mergeDeepWith((oldValue, newValue, key)=> {
+ return newValue === null ? oldValue : newValue
+ }, arrToMap(response, ArticleRecord))
+ })
case LOAD_ARTICLE + START:
return articles.setIn(['entities', payload.id, 'loading'], true)