translations and import of the i18n lib to be usable

This commit is contained in:
Richard 2020-01-19 14:49:51 +01:00
parent 4b9b73e6ef
commit eaac033640
2 changed files with 30 additions and 30 deletions

View file

@ -231,27 +231,27 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
)} )}
{post.removed && ( {post.removed && (
<small className="ml-2 text-muted font-italic"> <small className="ml-2 text-muted font-italic">
<T i18nKey="removed">#</T> { i18n.t('removed') }
</small> </small>
)} )}
{post.deleted && ( {post.deleted && (
<small className="ml-2 text-muted font-italic"> <small className="ml-2 text-muted font-italic">
<T i18nKey="deleted">#</T> { i18n.t('deleted') }
</small> </small>
)} )}
{post.locked && ( {post.locked && (
<small className="ml-2 text-muted font-italic"> <small className="ml-2 text-muted font-italic">
<T i18nKey="locked">#</T> { i18n.t('locked') }
</small> </small>
)} )}
{post.stickied && ( {post.stickied && (
<small className="ml-2 text-muted font-italic"> <small className="ml-2 text-muted font-italic">
<T i18nKey="stickied">#</T> { i18n.t('stickied') }
</small> </small>
)} )}
{post.nsfw && ( {post.nsfw && (
<small className="ml-2 text-muted font-italic"> <small className="ml-2 text-muted font-italic">
<T i18nKey="nsfw">#</T> { i18n.t('nsfw') }
</small> </small>
)} )}
</div> </div>
@ -273,17 +273,17 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</Link> </Link>
{this.isMod && ( {this.isMod && (
<span className="mx-1 badge badge-light"> <span className="mx-1 badge badge-light">
<T i18nKey="mod">#</T> { i18n.t('mod') }
</span> </span>
)} )}
{this.isAdmin && ( {this.isAdmin && (
<span className="mx-1 badge badge-light"> <span className="mx-1 badge badge-light">
<T i18nKey="admin">#</T> { i18n.t('admin') }
</span> </span>
)} )}
{(post.banned_from_community || post.banned) && ( {(post.banned_from_community || post.banned) && (
<span className="mx-1 badge badge-danger"> <span className="mx-1 badge badge-danger">
<T i18nKey="banned">#</T> { i18n.t('banned') }
</span> </span>
)} )}
{this.props.showCommunity && ( {this.props.showCommunity && (
@ -390,14 +390,14 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModRemoveShow)} onClick={linkEvent(this, this.handleModRemoveShow)}
> >
<T i18nKey="remove">#</T> { i18n.t('remove') }
</span> </span>
) : ( ) : (
<span <span
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModRemoveSubmit)} onClick={linkEvent(this, this.handleModRemoveSubmit)}
> >
<T i18nKey="restore">#</T> { i18n.t('restore') }
</span> </span>
)} )}
</li> </li>
@ -414,7 +414,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleModBanFromCommunityShow this.handleModBanFromCommunityShow
)} )}
> >
<T i18nKey="ban">#</T> { i18n.t('ban') }
</span> </span>
) : ( ) : (
<span <span
@ -424,7 +424,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleModBanFromCommunitySubmit this.handleModBanFromCommunitySubmit
)} )}
> >
<T i18nKey="unban">#</T> { i18n.t('unban') }
</span> </span>
)} )}
</li> </li>
@ -471,7 +471,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleTransferCommunity this.handleTransferCommunity
)} )}
> >
<T i18nKey="yes">#</T> { i18n.t('yes') }
</span> </span>
<span <span
class="pointer d-inline-block" class="pointer d-inline-block"
@ -480,7 +480,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleCancelShowConfirmTransferCommunity this.handleCancelShowConfirmTransferCommunity
)} )}
> >
<T i18nKey="no">#</T> { i18n.t('no') }
</span> </span>
</> </>
)} )}
@ -496,14 +496,14 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModBanShow)} onClick={linkEvent(this, this.handleModBanShow)}
> >
<T i18nKey="ban_from_site">#</T> { i18n.t('ban_from_site') }
</span> </span>
) : ( ) : (
<span <span
class="pointer" class="pointer"
onClick={linkEvent(this, this.handleModBanSubmit)} onClick={linkEvent(this, this.handleModBanSubmit)}
> >
<T i18nKey="unban_from_site">#</T> { i18n.t('unban_from_site') }
</span> </span>
)} )}
</li> </li>
@ -533,18 +533,18 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleShowConfirmTransferSite this.handleShowConfirmTransferSite
)} )}
> >
<T i18nKey="transfer_site">#</T> { i18n.t('transfer_site') }
</span> </span>
) : ( ) : (
<> <>
<span class="d-inline-block mr-1"> <span class="d-inline-block mr-1">
<T i18nKey="are_you_sure">#</T> { i18n.t('are_you_sure') }
</span> </span>
<span <span
class="pointer d-inline-block mr-1" class="pointer d-inline-block mr-1"
onClick={linkEvent(this, this.handleTransferSite)} onClick={linkEvent(this, this.handleTransferSite)}
> >
<T i18nKey="yes">#</T> { i18n.t('yes') }
</span> </span>
<span <span
class="pointer d-inline-block" class="pointer d-inline-block"
@ -553,7 +553,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.handleCancelShowConfirmTransferSite this.handleCancelShowConfirmTransferSite
)} )}
> >
<T i18nKey="no">#</T> { i18n.t('no') }
</span> </span>
</> </>
)} )}
@ -567,7 +567,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className="pointer" className="pointer"
onClick={linkEvent(this, this.handleViewSource)} onClick={linkEvent(this, this.handleViewSource)}
> >
<T i18nKey="view_source">#</T> { i18n.t('view_source') }
</span> </span>
</li> </li>
)} )}
@ -585,18 +585,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
onInput={linkEvent(this, this.handleModRemoveReasonChange)} onInput={linkEvent(this, this.handleModRemoveReasonChange)}
/> />
<button type="submit" class="btn btn-secondary"> <button type="submit" class="btn btn-secondary">
<T i18nKey="remove_post">#</T> { i18n.t('remove_post') }
</button> </button>
</form> </form>
)} )}
{this.state.showBanDialog && ( {this.state.showBanDialog && (
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}> <form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
<div class="form-group row"> <div class="form-group row">
<label class="col-form-label"> <label class="col-form-label" for="post-listing-reason">
<T i18nKey="reason">#</T> { i18n.t('reason') }
</label> </label>
<input <input
type="text" type="text"
id="post-listing-reason"
class="form-control mr-2" class="form-control mr-2"
placeholder={i18n.t('reason')} placeholder={i18n.t('reason')}
value={this.state.banReason} value={this.state.banReason}

View file

@ -2,6 +2,7 @@ import { Component } from 'inferno';
import { Link } from 'inferno-router'; import { Link } from 'inferno-router';
import { Post } from '../interfaces'; import { Post } from '../interfaces';
import { PostListing } from './post-listing'; import { PostListing } from './post-listing';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next'; import { T } from 'inferno-i18next';
interface PostListingsProps { interface PostListingsProps {
@ -30,14 +31,12 @@ export class PostListings extends Component<PostListingsProps, any> {
)) ))
) : ( ) : (
<> <>
<div> <h2>
<T i18nKey="no_posts">#</T> { i18n.t('no_posts') }
</div> </h2>
{this.props.showCommunity !== undefined && ( {this.props.showCommunity !== undefined && (
<div> <div>
<T i18nKey="subscribe_to_communities"> <Link to="/communities">{ i18n.t('subscribe_to_communities') }</Link>
#<Link to="/communities">#</Link>
</T>
</div> </div>
)} )}
</> </>