Skip to content

Commit

Permalink
Use the new i18nChannel where appropriate (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jun 13, 2022
1 parent 1d71075 commit 1697cfd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions frontend/src/i18n/en/translation_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"between-landing-search": " or "
}
},
"source": {
"delete-confirm": "\nAre you sure you want to delete this source?\nIf you delete this source, all its annotation will be deleted as well, including any annotations that other users may have made.\nThis cannot be undone.\n"
},
"register": {
"thanks": {
"begin": "Thank you for signing up. You can now "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { extend } from 'lodash';
import * as i18next from 'i18next';

import explorerChannel from '../explorer/explorer-radio';
import { announceRoute } from '../explorer/utilities';
import FieldEditingPanel from '../panel-common/field-editing-panel';
import i18nChannel from '../i18n/radio';

import ExternalResourceMultifield from './external-resources-multifield';

Expand All @@ -25,6 +25,9 @@ export default class ExternalResourcesEditView extends FieldEditingPanel {
}
}

extend(ExternalResourcesEditView.prototype, {
title: i18next.t('item.edit-external-title', 'Edit external resources'),
});
(async function() {
const i18next = await i18nChannel.request('i18next');
extend(ExternalResourcesEditView.prototype, {
title: i18next.t('item.edit-external-title', 'Edit external resources'),
});
}());
11 changes: 7 additions & 4 deletions frontend/src/panel-related-items/related-items-edit-view.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { extend } from 'lodash';
import * as i18next from 'i18next';

import explorerChannel from '../explorer/explorer-radio';
import { announceRoute } from '../explorer/utilities';
import FieldEditingPanel from '../panel-common/field-editing-panel';
import i18nChannel from '../i18n/radio';

import RelatedItemsMultifield from './related-items-edit-multifield';

Expand All @@ -25,6 +25,9 @@ export default class RelatedItemsEditor extends FieldEditingPanel {
}
}

extend(RelatedItemsEditor.prototype, {
title: i18next.t('item.edit-related-title', 'Edit related items'),
});
(async function() {
const i18next = await i18nChannel.request('i18next');
extend(RelatedItemsEditor.prototype, {
title: i18next.t('item.edit-related-title', 'Edit related items'),
});
}());
11 changes: 8 additions & 3 deletions frontend/src/panel-source/source-metadata-view.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { extend } from 'lodash';
import * as i18next from 'i18next';

import View from '../core/view';
import userChannel from '../common-user/user-radio';
import { dcterms } from '../common-rdf/ns';
import Node, { isNode } from '../common-rdf/node';
import { getLabel, getTurtleTerm } from '../utilities/linked-data-utilities';
import explorerChannel from '../explorer/explorer-radio';
import i18nChannel from '../i18n/radio';

import metadataTemplate from './source-metadata-template';

Expand All @@ -18,11 +18,16 @@ const excludedProperties = [
'owl:sameAs'
];

const sourceDeletionDialog = i18next.t('source.delete-confirm', `
let sourceDeletionDialog: string;
const dialogDefault = `
Are you sure you want to delete this source?
If you delete this source, all its annotation will be deleted as well, including any annotations that other users may have made.
This cannot be undone.
`);
`;
(async function() {
const i18next = await i18nChannel.request('i18next');
sourceDeletionDialog = i18next.t('source.delete-confirm', dialogDefault);
}());

export default class MetadataView extends View {
/**
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/semantic-search/dropdown-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as i18next from 'i18next';

import Collection from '../core/collection';
import { xsd } from '../common-rdf/ns';
import i18nChannel from '../i18n/radio';

/**
* In this module, we define the logic operators, filters and option groups
Expand Down Expand Up @@ -141,8 +142,7 @@ function translateCollection(collection) {
collection.each(translateLabel);
}

function translateAll() {
(async function() {
await i18nChannel.request('i18next');
each([logic, filters, groupLabels], translateCollection);
}

history.once('route notfound', translateAll);
}());
9 changes: 7 additions & 2 deletions frontend/src/snippet/snippet-view.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { extend } from 'lodash';
import * as i18next from 'i18next';

import View from '../core/view';
import FlatItem from '../common-adapters/flat-item-model';
import i18nChannel from '../i18n/radio';

import snippetTemplate from './snippet-template';

export default class SnippetView extends View<FlatItem> {
ellipsis = i18next.t('interpunction.paragraph-ellipsis', '(...)');
ellipsis: string;
trimmedTitle: boolean;
trimmedStart: boolean;
trimmedEnd: boolean;
Expand Down Expand Up @@ -138,3 +138,8 @@ extend(SnippetView.prototype, {
className: 'snippet',
template: snippetTemplate,
});

(async function() {
const i18next = await i18nChannel.request('i18next');
SnippetView.prototype.ellipsis = i18next.t('interpunction.paragraph-ellipsis', '(...)');
}());

0 comments on commit 1697cfd

Please sign in to comment.