translation interpolation for site-form and sort-select

This commit is contained in:
Richard 2020-01-19 14:49:25 +01:00
parent 7effedf61d
commit 4b9b73e6ef
3 changed files with 26 additions and 21 deletions

View file

@ -65,7 +65,7 @@ export class PasswordChange extends Component<any, State> {
<div class="row"> <div class="row">
<div class="col-12 col-lg-6 offset-lg-3 mb-4"> <div class="col-12 col-lg-6 offset-lg-3 mb-4">
<h5> <h5>
<T i18nKey="password_change">#</T> { i18n.t('password_change') }
</h5> </h5>
{this.passwordChangeForm()} {this.passwordChangeForm()}
</div> </div>

View file

@ -54,12 +54,13 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
: capitalizeFirstLetter(i18n.t('name')) : capitalizeFirstLetter(i18n.t('name'))
} ${i18n.t('your_site')}`}</h5> } ${i18n.t('your_site')}`}</h5>
<div class="form-group row"> <div class="form-group row">
<label class="col-12 col-form-label"> <label class="col-12 col-form-label" for="create-site-name">
<T i18nKey="name">#</T> { i18n.t('name') }
</label> </label>
<div class="col-12"> <div class="col-12">
<input <input
type="text" type="text"
id="create-site-name"
class="form-control" class="form-control"
value={this.state.siteForm.name} value={this.state.siteForm.name}
onInput={linkEvent(this, this.handleSiteNameChange)} onInput={linkEvent(this, this.handleSiteNameChange)}
@ -70,12 +71,13 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-12 col-form-label"> <label class="col-12 col-form-label" for="create-site-sidebar">
<T i18nKey="sidebar">#</T> { i18n.t('sidebar') }
</label> </label>
<div class="col-12"> <div class="col-12">
<textarea <textarea
value={this.state.siteForm.description} value={this.state.siteForm.description}
id="create-site-sidebar"
onInput={linkEvent(this, this.handleSiteDescriptionChange)} onInput={linkEvent(this, this.handleSiteDescriptionChange)}
class="form-control" class="form-control"
rows={3} rows={3}
@ -88,12 +90,13 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
<div class="form-check"> <div class="form-check">
<input <input
class="form-check-input" class="form-check-input"
id="create-site-downvotes"
type="checkbox" type="checkbox"
checked={this.state.siteForm.enable_downvotes} checked={this.state.siteForm.enable_downvotes}
onChange={linkEvent(this, this.handleSiteEnableDownvotesChange)} onChange={linkEvent(this, this.handleSiteEnableDownvotesChange)}
/> />
<label class="form-check-label"> <label class="form-check-label" for="create-site-downvotes">
<T i18nKey="enable_downvotes">#</T> { i18n.t('enable_downvotes') }
</label> </label>
</div> </div>
</div> </div>
@ -103,12 +106,13 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
<div class="form-check"> <div class="form-check">
<input <input
class="form-check-input" class="form-check-input"
id="create-site-enable-nsfw"
type="checkbox" type="checkbox"
checked={this.state.siteForm.enable_nsfw} checked={this.state.siteForm.enable_nsfw}
onChange={linkEvent(this, this.handleSiteEnableNsfwChange)} onChange={linkEvent(this, this.handleSiteEnableNsfwChange)}
/> />
<label class="form-check-label"> <label class="form-check-label" for="create-site-enable-nsfw">
<T i18nKey="enable_nsfw">#</T> { i18n.t('enable_nsfw') }
</label> </label>
</div> </div>
</div> </div>
@ -118,6 +122,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
<div class="form-check"> <div class="form-check">
<input <input
class="form-check-input" class="form-check-input"
id="create-site-open-registration"
type="checkbox" type="checkbox"
checked={this.state.siteForm.open_registration} checked={this.state.siteForm.open_registration}
onChange={linkEvent( onChange={linkEvent(
@ -125,8 +130,8 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.handleSiteOpenRegistrationChange this.handleSiteOpenRegistrationChange
)} )}
/> />
<label class="form-check-label"> <label class="form-check-label" for="create-site-open-registration">
<T i18nKey="open_registration">#</T> { i18n.t('open_registration') }
</label> </label>
</div> </div>
</div> </div>
@ -150,7 +155,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
class="btn btn-secondary" class="btn btn-secondary"
onClick={linkEvent(this, this.handleCancel)} onClick={linkEvent(this, this.handleCancel)}
> >
<T i18nKey="cancel">#</T> { i18n.t('cancel') }
</button> </button>
)} )}
</div> </div>

View file

@ -1,6 +1,6 @@
import { Component, linkEvent } from 'inferno'; import { Component, linkEvent } from 'inferno';
import { SortType } from '../interfaces'; import { SortType } from '../interfaces';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next'; import { T } from 'inferno-i18next';
interface SortSelectProps { interface SortSelectProps {
@ -31,31 +31,31 @@ export class SortSelect extends Component<SortSelectProps, SortSelectState> {
class="custom-select custom-select-sm w-auto" class="custom-select custom-select-sm w-auto"
> >
<option disabled> <option disabled>
<T i18nKey="sort_type">#</T> { i18n.t('sort_type') }
</option> </option>
{!this.props.hideHot && ( {!this.props.hideHot && (
<option value={SortType.Hot}> <option value={SortType.Hot}>
<T i18nKey="hot">#</T> { i18n.t('hot') }
</option> </option>
)} )}
<option value={SortType.New}> <option value={SortType.New}>
<T i18nKey="new">#</T> { i18n.t('new') }
</option> </option>
<option disabled></option> <option disabled></option>
<option value={SortType.TopDay}> <option value={SortType.TopDay}>
<T i18nKey="top_day">#</T> { i18n.t('top_day') }
</option> </option>
<option value={SortType.TopWeek}> <option value={SortType.TopWeek}>
<T i18nKey="week">#</T> { i18n.t('week') }
</option> </option>
<option value={SortType.TopMonth}> <option value={SortType.TopMonth}>
<T i18nKey="month">#</T> { i18n.t('month') }
</option> </option>
<option value={SortType.TopYear}> <option value={SortType.TopYear}>
<T i18nKey="year">#</T> { i18n.t('year') }
</option> </option>
<option value={SortType.TopAll}> <option value={SortType.TopAll}>
<T i18nKey="all">#</T> { i18n.t('all') }
</option> </option>
</select> </select>
); );