@@ -3,16 +3,51 @@ 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 , getTranslations } from 'libs/i18n/i18nHelper' ;
13
+ import { defaultMessages , defaultLocale } from 'libs/i18n/default' ;
14
+
15
+ export default class I18nWrapper extends BaseComponent {
16
+ constructor ( props ) {
17
+ super ( props ) ;
18
+
19
+ this . state = {
20
+ locale : defaultLocale ,
21
+ } ;
22
+
23
+ _ . bindAll ( this , 'handleSetLocale' ) ;
24
+ }
25
+
26
+ handleSetLocale ( locale ) {
27
+ this . setState ( { locale : locale } ) ;
28
+ }
29
+
30
+ render ( ) {
31
+ const { locale } = this . state ;
32
+ const messages = getTranslations ( locale ) ;
33
+ const InjectedSimpleCommentScreen = injectIntl ( SimpleCommentScreen ) ;
34
+
35
+ return (
36
+ < IntlProvider locale = { locale } key = { locale } messages = { messages } >
37
+ < InjectedSimpleCommentScreen
38
+ { ...this . props }
39
+ locale = { locale }
40
+ handleSetLocale = { this . handleSetLocale }
41
+ />
42
+ </ IntlProvider >
43
+ ) ;
44
+ }
45
+ }
46
+
47
+ class SimpleCommentScreen extends BaseComponent {
48
+ constructor ( props ) {
49
+ super ( props ) ;
12
50
13
- export default class SimpleCommentScreen extends BaseComponent {
14
- constructor ( props , context ) {
15
- super ( props , context ) ;
16
51
this . state = {
17
52
$$comments : Immutable . fromJS ( [ ] ) ,
18
53
isSaving : false ,
@@ -67,6 +102,8 @@ export default class SimpleCommentScreen extends BaseComponent {
67
102
}
68
103
69
104
render ( ) {
105
+ const { handleSetLocale, locale, intl } = this . props ;
106
+ const { formatMessage } = intl ;
70
107
const cssTransitionGroupClassNames = {
71
108
enter : css . elementEnter ,
72
109
enterActive : css . elementEnterActive ,
@@ -75,12 +112,16 @@ export default class SimpleCommentScreen extends BaseComponent {
75
112
} ;
76
113
77
114
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 >
115
+ < div className = 'commentBox container' >
116
+ < h2 >
117
+ { formatMessage ( defaultMessages . comments ) }
118
+ </ h2 >
119
+ { SelectLanguage ( handleSetLocale , locale ) }
120
+ < ul >
121
+ < li > { formatMessage ( defaultMessages . descriptionSupportMarkdown ) } </ li >
122
+ < li > { formatMessage ( defaultMessages . descriptionDeleteRule ) } </ li >
123
+ < li > { formatMessage ( defaultMessages . descriptionSubmitRule ) } </ li >
124
+ </ ul >
84
125
< CommentForm
85
126
isSaving = { this . state . isSaving }
86
127
actions = { { submitComment : this . handleCommentSubmit } }
0 commit comments