diff options
author | Dessalines <dessalines@users.noreply.github.com> | 2019-08-09 17:14:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-09 17:14:43 -0700 |
commit | 536c3f491546b4546f43a46e7a1a699ca9ac2934 (patch) | |
tree | f080c86e51b9660560ac493cb7f6d9676ea12fbe /ui/src/components/comment-form.tsx | |
parent | 5a1e8aa645c9f0898e765b45c2f362308292db26 (diff) |
Adding support for internationalization / i18n (#189)
* Still not working
* Starting to work on internationalization
* Main done.
* i18n translations first pass.
* Localization testing mostly done.
* Second front end pass.
* Added a few more translations.
* Adding back end translations.
Diffstat (limited to 'ui/src/components/comment-form.tsx')
-rw-r--r-- | ui/src/components/comment-form.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 5181e45e..ed62fcf5 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -1,7 +1,10 @@ import { Component, linkEvent } from 'inferno'; import { CommentNode as CommentNodeI, CommentForm as CommentFormI } from '../interfaces'; +import { capitalizeFirstLetter } from '../utils'; import { WebSocketService, UserService } from '../services'; import * as autosize from 'autosize'; +import { i18n } from '../i18next'; +import { T } from 'inferno-i18next'; interface CommentFormProps { postId?: number; @@ -25,12 +28,13 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { post_id: this.props.node ? this.props.node.comment.post_id : this.props.postId, creator_id: UserService.Instance.user ? UserService.Instance.user.id : null, }, - buttonTitle: !this.props.node ? "Post" : this.props.edit ? "Edit" : "Reply", + buttonTitle: !this.props.node ? capitalizeFirstLetter(i18n.t('post')) : this.props.edit ? capitalizeFirstLetter(i18n.t('edit')) : capitalizeFirstLetter(i18n.t('reply')), } constructor(props: any, context: any) { super(props, context); + this.state = this.emptyState; if (this.props.node) { @@ -62,7 +66,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { <div class="row"> <div class="col-sm-12"> <button type="submit" class="btn btn-sm btn-secondary mr-2" disabled={this.props.disabled}>{this.state.buttonTitle}</button> - {this.props.node && <button type="button" class="btn btn-sm btn-secondary" onClick={linkEvent(this, this.handleReplyCancel)}>Cancel</button>} + {this.props.node && <button type="button" class="btn btn-sm btn-secondary" onClick={linkEvent(this, this.handleReplyCancel)}><T i18nKey="cancel">#</T></button>} </div> </div> </form> @@ -84,7 +88,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { if (i.props.node) { i.props.onReplyCancel(); } - + autosize.update(document.querySelector('textarea')); } |