@@ -3,16 +3,51 @@ import Immutable from 'immutable';
33import _ from 'lodash' ;
44import React from 'react' ;
55import ReactOnRails from 'react-on-rails' ;
6- 6+ import { IntlProvider , injectIntl , intlShape } from 'react-intl' ;
77import BaseComponent from 'libs/components/BaseComponent' ;
88
99import CommentForm from '../CommentBox/CommentForm/CommentForm' ;
1010import CommentList from '../CommentBox/CommentList/CommentList' ;
1111import 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 ) ;
1250
13- export default class SimpleCommentScreen extends BaseComponent {
14- constructor ( props , context ) {
15- super ( props , context ) ;
1651 this . state = {
1752 $$comments : Immutable . fromJS ( [ ] ) ,
1853 isSaving : false ,
@@ -67,6 +102,8 @@ export default class SimpleCommentScreen extends BaseComponent {
67102 }
68103
69104 render ( ) {
105+ const { handleSetLocale, locale, intl } = this . props ;
106+ const { formatMessage } = intl ;
70107 const cssTransitionGroupClassNames = {
71108 enter : css . elementEnter ,
72109 enterActive : css . elementEnterActive ,
@@ -75,12 +112,16 @@ export default class SimpleCommentScreen extends BaseComponent {
75112 } ;
76113
77114 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 >
84125 < CommentForm
85126 isSaving = { this . state . isSaving }
86127 actions = { { submitComment : this . handleCommentSubmit } }
0 commit comments