Extracted strings and fixes on localization support

Language chooser in the UI
This commit is contained in:
Tomas Bures 2018-11-18 21:31:22 +01:00
parent 9f449c0a2f
commit dc7789c17b
126 changed files with 2919 additions and 2028 deletions

View file

@ -2,7 +2,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { translate } from 'react-i18next';
import { withTranslation } from '../lib/i18n';
import {requiresAuthenticatedUser, withPageHelpers, Title, NavButton} from '../lib/page';
import { withForm, Form, FormSendMethod, InputField, TextArea, ButtonRow, Button, TreeTableSelect } from '../lib/form';
import axios from '../lib/axios';
@ -13,7 +13,7 @@ import mailtrainConfig from 'mailtrainConfig';
import {getGlobalNamespaceId} from "../../../shared/namespaces";
import {getUrl} from "../lib/urls";
@translate()
@withTranslation()
@withForm
@withPageHelpers
@withErrorHandling
@ -89,14 +89,14 @@ export default class CUD extends Component {
const t = this.props.t;
if (!state.getIn(['name', 'value']).trim()) {
state.setIn(['name', 'error'], t('Name must not be empty'));
state.setIn(['name', 'error'], t('nameMustNotBeEmpty'));
} else {
state.setIn(['name', 'error'], null);
}
if (!this.isEditGlobal()) {
if (!state.getIn(['namespace', 'value'])) {
state.setIn(['namespace', 'error'], t('Parent Namespace must be selected'));
state.setIn(['namespace', 'error'], t('parentNamespaceMustBeSelected'));
} else {
state.setIn(['namespace', 'error'], null);
}
@ -117,23 +117,23 @@ export default class CUD extends Component {
try {
this.disableForm();
this.setFormStatusMessage('info', t('Saving ...'));
this.setFormStatusMessage('info', t('saving'));
const submitSuccessful = await this.validateAndSendFormValuesToURL(sendMethod, url);
if (submitSuccessful) {
this.navigateToWithFlashMessage('/namespaces', 'success', t('Namespace saved'));
this.navigateToWithFlashMessage('/namespaces', 'success', t('namespaceSaved'));
} else {
this.enableForm();
this.setFormStatusMessage('warning', t('There are errors in the form. Please fix them and submit again.'));
this.setFormStatusMessage('warning', t('thereAreErrorsInTheFormPleaseFixThemAnd'));
}
} catch (error) {
if (error instanceof interoperableErrors.LoopDetectedError) {
this.setFormStatusMessage('danger',
<span>
<strong>{t('Your updates cannot be saved.')}</strong>{' '}
{t('There has been a loop detected in the assignment of the parent namespace. This is most likely because someone else has changed the parent of some namespace in the meantime. Refresh your page to start anew. Please note that your changes will be lost.')}
<strong>{t('yourUpdatesCannotBeSaved')}</strong>{' '}
{t('thereHasBeenALoopDetectedInTheAssignment')}
</span>
);
return;
@ -142,8 +142,8 @@ export default class CUD extends Component {
if (error instanceof interoperableErrors.DependencyNotFoundError) {
this.setFormStatusMessage('danger',
<span>
<strong>{t('Your updates cannot be saved.')}</strong>{' '}
{t('It seems that the parent namespace has been deleted in the meantime. Refresh your page to start anew. Please note that your changes will be lost.')}
<strong>{t('yourUpdatesCannotBeSaved')}</strong>{' '}
{t('itSeemsThatTheParentNamespaceHasBeen')}
</span>
);
return;
@ -167,22 +167,22 @@ export default class CUD extends Component {
deleteUrl={`rest/namespaces/${this.props.entity.id}`}
backUrl={`/namespaces/${this.props.entity.id}/edit`}
successUrl="/namespaces"
deletingMsg={t('Deleting namespace ...')}
deletedMsg={t('Namespace deleted')} />
deletingMsg={t('deletingNamespace')}
deletedMsg={t('namespaceDeleted')} />
}
<Title>{isEdit ? t('Edit Namespace') : t('Create Namespace')}</Title>
<Title>{isEdit ? t('editNamespace') : t('createNamespace')}</Title>
<Form stateOwner={this} onSubmitAsync={::this.submitHandler}>
<InputField id="name" label={t('Name')}/>
<TextArea id="description" label={t('Description')}/>
<InputField id="name" label={t('name')}/>
<TextArea id="description" label={t('description')}/>
{!this.isEditGlobal() &&
<TreeTableSelect id="namespace" label={t('Parent Namespace')} data={this.state.treeData}/>}
<TreeTableSelect id="namespace" label={t('parentNamespace')} data={this.state.treeData}/>}
<ButtonRow>
<Button type="submit" className="btn-primary" icon="ok" label={t('Save')}/>
{canDelete && <NavButton className="btn-danger" icon="remove" label={t('Delete')} linkTo={`/namespaces/${this.props.entity.id}/delete`}/>}
<Button type="submit" className="btn-primary" icon="ok" label={t('save')}/>
{canDelete && <NavButton className="btn-danger" icon="remove" label={t('delete')} linkTo={`/namespaces/${this.props.entity.id}/delete`}/>}
</ButtonRow>
</Form>
</div>

View file

@ -1,7 +1,7 @@
'use strict';
import React, { Component } from 'react';
import { translate } from 'react-i18next';
import { withTranslation } from '../lib/i18n';
import { requiresAuthenticatedUser, withPageHelpers, Title, Toolbar, NavButton } from '../lib/page';
import { TreeTable } from '../lib/tree';
import { withErrorHandling, withAsyncErrorHandler } from '../lib/error-handling';
@ -15,7 +15,7 @@ import {
} from "../lib/modals";
import {getGlobalNamespaceId} from "../../../shared/namespaces";
@translate()
@withTranslation()
@withErrorHandling
@withPageHelpers
@requiresAuthenticatedUser
@ -54,14 +54,14 @@ export default class List extends Component {
if (node.data.permissions.includes('edit')) {
actions.push({
label: <Icon icon="edit" title={t('Edit')}/>,
label: <Icon icon="edit" title={t('edit')}/>,
link: `/namespaces/${node.key}/edit`
});
}
if (node.data.permissions.includes('share')) {
actions.push({
label: <Icon icon="share-alt" title={t('Share')}/>,
label: <Icon icon="share-alt" title={t('share')}/>,
link: `/namespaces/${node.key}/share`
});
}
@ -75,14 +75,14 @@ export default class List extends Component {
return (
<div>
{tableDeleteDialogRender(this, `rest/namespaces`, t('Deleting namespace ...'), t('Namespace deleted'))}
{tableDeleteDialogRender(this, `rest/namespaces`, t('deletingNamespace'), t('namespaceDeleted'))}
{this.state.createPermitted &&
<Toolbar>
<NavButton linkTo="/namespaces/create" className="btn-primary" icon="plus" label={t('Create Namespace')}/>
<NavButton linkTo="/namespaces/create" className="btn-primary" icon="plus" label={t('createNamespace')}/>
</Toolbar>
}
<Title>{t('Namespaces')}</Title>
<Title>{t('namespaces')}</Title>
<TreeTable ref={node => this.table = node} withHeader withDescription dataUrl="rest/namespaces-tree" actions={actions} />
</div>

View file

@ -8,33 +8,33 @@ import Share from '../shares/Share';
function getMenus(t) {
return {
namespaces: {
title: t('Namespaces'),
title: t('namespaces'),
link: '/namespaces',
panelComponent: List,
children: {
':namespaceId([0-9]+)': {
title: resolved => t('Namespace "{{name}}"', {name: resolved.namespace.name}),
title: resolved => t('namespaceName', {name: resolved.namespace.name}),
resolve: {
namespace: params => `rest/namespaces/${params.namespaceId}`
},
link: params => `/namespaces/${params.namespaceId}/edit`,
navs: {
':action(edit|delete)': {
title: t('Edit'),
title: t('edit'),
link: params => `/namespaces/${params.namespaceId}/edit`,
visible: resolved => resolved.namespace.permissions.includes('edit'),
panelRender: props => <CUD action={props.match.params.action} entity={props.resolved.namespace} />
},
share: {
title: t('Share'),
title: t('share'),
link: params => `/namespaces/${params.namespaceId}/share`,
visible: resolved => resolved.namespace.permissions.includes('share'),
panelRender: props => <Share title={t('Share')} entity={props.resolved.namespace} entityTypeId="namespace" />
panelRender: props => <Share title={t('share')} entity={props.resolved.namespace} entityTypeId="namespace" />
}
}
},
create: {
title: t('Create'),
title: t('create'),
panelRender: props => <CUD action="create" />
},
}