@@ -3,16 +3,52 @@ import Immutable from 'immutable';
3
3
import _ from 'lodash' ;
4
4
import React from 'react' ;
5
5
import ReactOnRails from 'react-on-rails' ;
6
-
6
+ import { IntlProvider , injectIntl , intlShape } from 'react-intl' ;
7
7
import BaseComponent from 'libs/components/BaseComponent' ;
8
8
9
9
import CommentForm from '../CommentBox/CommentForm/CommentForm' ;
10
10
import CommentList from '../CommentBox/CommentList/CommentList' ;
11
11
import css from './SimpleCommentScreen.scss' ;
12
+ import { SelectLanguage } from 'libs/i18n/selectLanguage' ;
13
+ import { defaultMessages , defaultLocale } from 'libs/i18n/default' ;
14
+ import { translations } from 'libs/i18n/translations' ;
15
+
16
+ export default class I18nWrapper extends BaseComponent {
17
+ constructor ( props ) {
18
+ super ( props ) ;
19
+
20
+ this . state = {
21
+ locale : defaultLocale ,
22
+ } ;
23
+
24
+ _ . bindAll ( this , 'handleSetLocale' ) ;
25
+ }
26
+
27
+ handleSetLocale ( locale ) {
28
+ this . setState ( { locale : locale } ) ;
29
+ }
30
+
31
+ render ( ) {
32
+ const { locale } = this . state ;
33
+ const messages = translations [ locale ] ;
34
+ const InjectedSimpleCommentScreen = injectIntl ( SimpleCommentScreen ) ;
35
+
36
+ return (
37
+ < IntlProvider locale = { locale } key = { locale } messages = { messages } >
38
+ < InjectedSimpleCommentScreen
39
+ { ...this . props }
40
+ locale = { locale }
41
+ handleSetLocale = { this . handleSetLocale }
42
+ />
43
+ </ IntlProvider >
44
+ ) ;
45
+ }
46
+ }
47
+
48
+ class SimpleCommentScreen extends BaseComponent {
49
+ constructor ( props ) {
50
+ super ( props ) ;
12
51
13
- export default class SimpleCommentScreen extends BaseComponent {
14
- constructor ( props , context ) {
15
- super ( props , context ) ;
16
52
this . state = {
17
53
$$comments : Immutable . fromJS ( [ ] ) ,
18
54
isSaving : false ,
@@ -67,6 +103,8 @@ export default class SimpleCommentScreen extends BaseComponent {
67
103
}
68
104
69
105
render ( ) {
106
+ const { handleSetLocale, locale, intl } = this . props ;
107
+ const { formatMessage } = intl ;
70
108
const cssTransitionGroupClassNames = {
71
109
enter : css . elementEnter ,
72
110
enterActive : css . elementEnterActive ,
@@ -75,12 +113,16 @@ export default class SimpleCommentScreen extends BaseComponent {
75
113
} ;
76
114
77
115
return (
78
- < div className = "commentBox container" >
79
- < h2 > Comments</ h2 >
80
- < p >
81
- Text take Github Flavored Markdown. Comments older than 24 hours are deleted.< br />
82
- < b > Name</ b > is preserved. < b > Text</ b > is reset, between submits.
83
- </ p >
116
+ < div className = 'commentBox container' >
117
+ < h2 >
118
+ { formatMessage ( defaultMessages . comments ) }
119
+ </ h2 >
120
+ { SelectLanguage ( handleSetLocale , locale ) }
121
+ < ul >
122
+ < li > { formatMessage ( defaultMessages . descriptionSupportMarkdown ) } </ li >
123
+ < li > { formatMessage ( defaultMessages . descriptionDeleteRule ) } </ li >
124
+ < li > { formatMessage ( defaultMessages . descriptionSubmitRule ) } </ li >
125
+ </ ul >
84
126
< CommentForm
85
127
isSaving = { this . state . isSaving }
86
128
actions = { { submitComment : this . handleCommentSubmit } }
0 commit comments