summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-form.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/post-form.tsx')
-rw-r--r--ui/src/components/post-form.tsx22
1 files changed, 12 insertions, 10 deletions
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx
index 54b3ca44..8aa7a5ea 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -4,8 +4,10 @@ import { Subscription } from "rxjs";
import { retryWhen, delay, take } from 'rxjs/operators';
import { PostForm as PostFormI, Post, PostResponse, UserOperation, Community, ListCommunitiesResponse, ListCommunitiesForm, SortType, SearchForm, SearchType, SearchResponse } from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, getPageTitle, debounce } from '../utils';
+import { msgOp, getPageTitle, debounce, capitalizeFirstLetter } from '../utils';
import * as autosize from 'autosize';
+import { i18n } from '../i18next';
+import { T } from 'inferno-i18next';
interface PostFormProps {
post?: Post; // If a post is given, that means this is an edit
@@ -85,28 +87,28 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
<div>
<form onSubmit={linkEvent(this, this.handlePostSubmit)}>
<div class="form-group row">
- <label class="col-sm-2 col-form-label">URL</label>
+ <label class="col-sm-2 col-form-label"><T i18nKey="url">#</T></label>
<div class="col-sm-10">
<input type="url" class="form-control" value={this.state.postForm.url} onInput={linkEvent(this, debounce(this.handlePostUrlChange))} />
{this.state.suggestedTitle &&
- <div class="mt-1 text-muted small font-weight-bold pointer" onClick={linkEvent(this, this.copySuggestedTitle)}>copy suggested title: {this.state.suggestedTitle}</div>
+ <div class="mt-1 text-muted small font-weight-bold pointer" onClick={linkEvent(this, this.copySuggestedTitle)}><T i18nKey="copy_suggested_title" interpolation={{title: this.state.suggestedTitle}}>#</T></div>
}
</div>
</div>
<div class="form-group row">
- <label class="col-sm-2 col-form-label">Title</label>
+ <label class="col-sm-2 col-form-label"><T i18nKey="title">#</T></label>
<div class="col-sm-10">
<textarea value={this.state.postForm.name} onInput={linkEvent(this, debounce(this.handlePostNameChange))} class="form-control" required rows={2} minLength={3} maxLength={100} />
{this.state.suggestedPosts.length > 0 &&
<>
- <div class="my-1 text-muted small font-weight-bold">These posts might be related</div>
+ <div class="my-1 text-muted small font-weight-bold"><T i18nKey="related_posts">#</T></div>
<PostListings posts={this.state.suggestedPosts} />
</>
}
</div>
</div>
<div class="form-group row">
- <label class="col-sm-2 col-form-label">Body</label>
+ <label class="col-sm-2 col-form-label"><T i18nKey="body">#</T></label>
<div class="col-sm-10">
<textarea value={this.state.postForm.body} onInput={linkEvent(this, this.handlePostBodyChange)} class="form-control" rows={4} maxLength={10000} />
</div>
@@ -114,7 +116,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
{/* Cant change a community from an edit */}
{!this.props.post &&
<div class="form-group row">
- <label class="col-sm-2 col-form-label">Community</label>
+ <label class="col-sm-2 col-form-label"><T i18nKey="community">#</T></label>
<div class="col-sm-10">
<select class="form-control" value={this.state.postForm.community_id} onInput={linkEvent(this, this.handlePostCommunityChange)}>
{this.state.communities.map(community =>
@@ -129,8 +131,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
<button type="submit" class="btn btn-secondary mr-2">
{this.state.loading ?
<svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg> :
- this.props.post ? 'Save' : 'Create'}</button>
- {this.props.post && <button type="button" class="btn btn-secondary" onClick={linkEvent(this, this.handleCancel)}>Cancel</button>}
+ this.props.post ? capitalizeFirstLetter(i18n.t('save')) : capitalizeFirstLetter(i18n.t('Create'))}</button>
+ {this.props.post && <button type="button" class="btn btn-secondary" onClick={linkEvent(this, this.handleCancel)}><T i18nKey="cancel">#</T></button>}
</div>
</div>
</form>
@@ -201,7 +203,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(msg.error);
+ alert(i18n.t(msg.error));
this.state.loading = false;
this.setState(this.state);
return;