From 1236e78f3af0428e556701651855e5cec8292368 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Wed, 16 Mar 2022 14:34:38 +0100 Subject: [PATCH] Add i18next.t calls in more places (#451) --- frontend/src/explorer/explorer-event-controller.ts | 3 ++- frontend/src/item-metadata/item-metadata-view.ts | 5 +++-- frontend/src/panel-annotation/annotation-view.ts | 3 ++- .../panel-external-resources/external-resources-edit-view.ts | 3 ++- frontend/src/panel-related-items/related-items-edit-view.ts | 3 ++- .../src/panel-search-results/search-result-list-panel.ts | 3 ++- frontend/src/panel-source/source-metadata-view.ts | 5 +++-- frontend/src/snippet/snippet-view.ts | 3 ++- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/src/explorer/explorer-event-controller.ts b/frontend/src/explorer/explorer-event-controller.ts index 3b24d1f21..fdab4f511 100644 --- a/frontend/src/explorer/explorer-event-controller.ts +++ b/frontend/src/explorer/explorer-event-controller.ts @@ -311,10 +311,11 @@ class ExplorerEventController { landing = false; } const title = `${landing ? 'My' : 'Sample'} ${queryMode}`; + const i18nKey = title.toLowerCase().replace(' ', '_'); const endpoint = `${queryMode}:${landing ? 'user' : 'sample'}`; const collection = new FlatItemCollection(ldChannel.request(endpoint)); const browsePanel = new SearchResultListPanel({ - title, + title: i18next.t(i18nKey, title), collection, selectable: false, }); diff --git a/frontend/src/item-metadata/item-metadata-view.ts b/frontend/src/item-metadata/item-metadata-view.ts index 303485d43..c9a392d5d 100644 --- a/frontend/src/item-metadata/item-metadata-view.ts +++ b/frontend/src/item-metadata/item-metadata-view.ts @@ -1,7 +1,8 @@ import { ViewOptions as BaseOpt } from 'backbone'; import { extend } from 'lodash'; -import View from '../core/view'; +import * as i18next from 'i18next'; +import View from '../core/view'; import Node from '../common-rdf/node'; import itemMetadataTemplate from './item-metadata-template'; @@ -28,7 +29,7 @@ export default class ItemMetadataView extends View { } initialize(options: ViewOptions): void { - this.title = options.title || 'Item metadata'; + this.title = options.title || i18next.t('item_metadata', 'Item metadata'); this.render().listenTo(this.model, 'change', this.render); } diff --git a/frontend/src/panel-annotation/annotation-view.ts b/frontend/src/panel-annotation/annotation-view.ts index 8ee2b2ea2..9e1e1cda5 100644 --- a/frontend/src/panel-annotation/annotation-view.ts +++ b/frontend/src/panel-annotation/annotation-view.ts @@ -1,4 +1,5 @@ import { extend, includes } from 'lodash'; +import * as i18next from 'i18next'; import { CompositeView } from '../core/view'; import Node, { isNode } from '../common-rdf/node'; @@ -49,7 +50,7 @@ export default class AnnotationView extends CompositeView { if (annotation) { this.annotationMetadataView = new ItemMetadataView({ model: annotation, - title: 'Annotation metadata' + title: i18next.t('annotation_metadata', 'Annotation metadata') }); } } diff --git a/frontend/src/panel-external-resources/external-resources-edit-view.ts b/frontend/src/panel-external-resources/external-resources-edit-view.ts index 5677cae3a..72e7631fc 100644 --- a/frontend/src/panel-external-resources/external-resources-edit-view.ts +++ b/frontend/src/panel-external-resources/external-resources-edit-view.ts @@ -1,4 +1,5 @@ import { extend } from 'lodash'; +import * as i18next from 'i18next'; import explorerChannel from '../explorer/explorer-radio'; import { announceRoute } from '../explorer/utilities'; @@ -25,5 +26,5 @@ export default class ExternalResourcesEditView extends FieldEditingPanel { } extend(ExternalResourcesEditView.prototype, { - title: 'Edit external resources', + title: i18next.t('edit_external_resources', 'Edit external resources'), }); diff --git a/frontend/src/panel-related-items/related-items-edit-view.ts b/frontend/src/panel-related-items/related-items-edit-view.ts index 0b9bdfce3..e691a3a7c 100644 --- a/frontend/src/panel-related-items/related-items-edit-view.ts +++ b/frontend/src/panel-related-items/related-items-edit-view.ts @@ -1,4 +1,5 @@ import { extend } from 'lodash'; +import * as i18next from 'i18next'; import explorerChannel from '../explorer/explorer-radio'; import { announceRoute } from '../explorer/utilities'; @@ -25,5 +26,5 @@ export default class RelatedItemsEditor extends FieldEditingPanel { } extend(RelatedItemsEditor.prototype, { - title: 'Edit related items', + title: i18next.t('edit_related_items', 'Edit related items'), }); diff --git a/frontend/src/panel-search-results/search-result-list-panel.ts b/frontend/src/panel-search-results/search-result-list-panel.ts index ed04371e1..cf1410905 100644 --- a/frontend/src/panel-search-results/search-result-list-panel.ts +++ b/frontend/src/panel-search-results/search-result-list-panel.ts @@ -1,4 +1,5 @@ import { extend, get } from 'lodash'; +import * as i18next from 'i18next'; import { CompositeView, @@ -47,7 +48,7 @@ export default class SearchResultListPanel extends CompositeView { } initialize(options: ViewOptions): this { - this.title = options.title || 'Search Results'; + this.title = options.title || i18next.t('search_results', 'Search Results'); this.searchList = new SearchResultListView(options).render(); this.listenTo(this.collection, { focus: this.onFocus, diff --git a/frontend/src/panel-source/source-metadata-view.ts b/frontend/src/panel-source/source-metadata-view.ts index 3d8721ef6..b78b704dd 100644 --- a/frontend/src/panel-source/source-metadata-view.ts +++ b/frontend/src/panel-source/source-metadata-view.ts @@ -1,4 +1,5 @@ import { extend } from 'lodash'; +import * as i18next from 'i18next'; import View from '../core/view'; import userChannel from '../common-user/user-radio'; @@ -17,11 +18,11 @@ const excludedProperties = [ 'owl:sameAs' ]; -const sourceDeletionDialog = ` +const sourceDeletionDialog = i18next.t('source_delete_confirm', ` 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. -`; +`); export default class MetadataView extends View { /** diff --git a/frontend/src/snippet/snippet-view.ts b/frontend/src/snippet/snippet-view.ts index 7804449fa..d42d7b8df 100644 --- a/frontend/src/snippet/snippet-view.ts +++ b/frontend/src/snippet/snippet-view.ts @@ -1,4 +1,5 @@ import { extend } from 'lodash'; +import * as i18next from 'i18next'; import View from '../core/view'; import FlatItem from '../common-adapters/flat-item-model'; @@ -6,7 +7,7 @@ import FlatItem from '../common-adapters/flat-item-model'; import snippetTemplate from './snippet-template'; export default class SnippetView extends View { - ellipsis = "(...)"; + ellipsis = i18next.t('interpunction.paragraph_ellipsis', '(...)'); trimmedTitle: boolean; trimmedStart: boolean; trimmedEnd: boolean;