From d7d0d31b3362df0bf82448279a076454b7a207b3 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Wed, 16 Mar 2022 12:47:34 +0100 Subject: [PATCH] Add i18next.t calls to the source-related views (#451 #37) Adding these changes here as part of #517 instead of in #513 because the latter is outdated compared to the former with regard to these views. This is a follow-up on the previous commit, which regarded the templates. @JeltevanBoheemen FYI --- .../source-metadata/source-metadata-view.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/src/source-metadata/source-metadata-view.ts b/frontend/src/source-metadata/source-metadata-view.ts index dea1eec1..6ac707bf 100644 --- a/frontend/src/source-metadata/source-metadata-view.ts +++ b/frontend/src/source-metadata/source-metadata-view.ts @@ -1,5 +1,6 @@ import { extend } from 'lodash'; import { ViewOptions as BaseOpt } from 'backbone'; +import * as i18next from 'i18next'; import { rdfs, sourceOntology as sourceNS, sourceOntologyPrefix } from '../common-rdf/ns'; import ldChannel from '../common-rdf/radio'; @@ -83,23 +84,23 @@ export default class SourceMetadataView extends CompositeView { model: this.getNode('datePublished'), name: 'datePublished', required: true, - label: 'Publication date', - additionalHelpText: `ISO formatted - date with optional time and timezone, or free-form text`, + label: i18next.t('publication_date', 'Publication date'), + additionalHelpText: i18next.t('publication_date_help', `ISO formatted + date with optional time and timezone, or free-form text`), readonly: this.readonly }); this.creationDateField = new DateField({ model: this.getNode('dateCreated'), name: 'dateCreated', - label: 'Creation date (optional)', - additionalHelpText: 'If known and different from publishing date, specify creation date.', - readonly: this.readonly + label: i18next.t('creation_date_opt', 'Creation date (optional)'), + additionalHelpText: i18next.t('creation_date_help', 'If known and different from publishing date, specify creation date.'), + readonly: this.readonly }); this.retrievalDateField = new DateField({ model: this.getNode('dateRetrieved'), name: 'dateRetrieved', - label: 'Retrieval date (optional)', - additionalHelpText: 'Date (and optional time) at which the source was accessed or retrieved.', + label: i18next.t('retrieval_date_opt', 'Retrieval date (optional)'), + additionalHelpText: i18next.t('retrieval_date_help', 'Date (and optional time) at which the source was accessed or retrieved.'), readonly: this.readonly }); this.render(); @@ -142,7 +143,7 @@ export default class SourceMetadataView extends CompositeView { const value = this.$(`[name='` + `${changedField}` + `']`).val(); const existingValue = this.model.get(sourceNS(changedField)); if (existingValue !== [value]) { - this.trigger('valueChanged', changedField, value); + this.trigger('valueChanged', changedField, value); } } } @@ -157,4 +158,4 @@ extend(SourceMetadataView.prototype, { events: { 'change .input': 'updateModel' } -}) \ No newline at end of file +})