diff --git a/src/core/Classes.ts b/src/core/Classes.ts index c0ee98e1..749b5067 100644 --- a/src/core/Classes.ts +++ b/src/core/Classes.ts @@ -12,11 +12,13 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +import {SCThingType} from './Thing'; import {SCAcademicEvent, SCAcademicEventMeta} from './things/AcademicEvent'; import {SCArticle, SCArticleMeta} from './things/Article'; import {SCBook, SCBookMeta} from './things/Book'; import {SCBuilding, SCBuildingMeta} from './things/Building'; import {SCCatalog, SCCatalogMeta} from './things/Catalog'; +import {SCCourseOfStudies, SCCourseOfStudiesMeta} from './things/CourseOfStudies'; import {SCDateSeries, SCDateSeriesMeta} from './things/DateSeries'; import {SCDiff, SCDiffMeta} from './things/Diff'; import {SCDish, SCDishMeta} from './things/Dish'; @@ -39,30 +41,31 @@ import {SCVideo, SCVideoMeta} from './things/Video'; /** * A map of things, from type to meta data */ -export const SCClasses = { +export const SCClasses: { [K in SCThingType]: any } = { /* tslint:enable */ 'academic event': SCAcademicEventMeta, - article: SCArticleMeta, - book: SCBookMeta, - building: SCBuildingMeta, - catalog: SCCatalogMeta, + 'article': SCArticleMeta, + 'book': SCBookMeta, + 'building': SCBuildingMeta, + 'catalog': SCCatalogMeta, + 'course of studies': SCCourseOfStudiesMeta, 'date series': SCDateSeriesMeta, - diff: SCDiffMeta, - dish: SCDishMeta, - favorite: SCFavoriteMeta, - floor: SCFloorMeta, - message: SCMessageMeta, - organization: SCOrganizationMeta, - person: SCPersonMeta, + 'diff': SCDiffMeta, + 'dish': SCDishMeta, + 'favorite': SCFavoriteMeta, + 'floor': SCFloorMeta, + 'message': SCMessageMeta, + 'organization': SCOrganizationMeta, + 'person': SCPersonMeta, 'point of interest': SCPointOfInterestMeta, - room: SCRoomMeta, + 'room': SCRoomMeta, 'semester': SCSemesterMeta, - setting: SCSettingMeta, + 'setting': SCSettingMeta, 'sport course': SCSportCourseMeta, - ticket: SCTicketMeta, - todo: SCToDoMeta, - tour: SCTourMeta, - video: SCVideoMeta, + 'ticket': SCTicketMeta, + 'todo': SCToDoMeta, + 'tour': SCTourMeta, + 'video': SCVideoMeta, }; export type SCThingsWithoutDiff = @@ -71,6 +74,7 @@ export type SCThingsWithoutDiff = | SCBook | SCBuilding | SCCatalog + | SCCourseOfStudies | SCDateSeries | SCDish | SCFavorite diff --git a/src/core/Thing.ts b/src/core/Thing.ts index 16651e93..c90baa7f 100644 --- a/src/core/Thing.ts +++ b/src/core/Thing.ts @@ -14,7 +14,7 @@ */ import {SCOrganization} from './things/Organization'; import {SCPerson} from './things/Person'; -import {SCTranslations} from './types/i18n'; +import {SCMetaTranslations, SCTranslations} from './types/i18n'; import {SCISO8601Date} from './types/Time'; import {SCUuid} from './types/UUID'; @@ -187,41 +187,6 @@ export interface SCThingUserOrigin extends SCThingOrigin { updated?: SCISO8601Date; } -/** - * Meta information about things - */ -export class SCThingMeta { - /** - * Translations of fields - */ - static fieldTranslations: any = { - de: { - alternateNames: 'alternative Namen', - description: 'Beschreibung', - image: 'Bild', - name: 'Name', - translations: 'Übersetzungen', - type: 'Typ', - uid: 'Identifikation', - url: 'URL', - }, - en: { - alternateNames: 'alternate names', - description: 'description', - uid: 'identification', - }, - }; - - /** - * Translations of values of fields - */ - static fieldValueTranslations: any = { - de: { - type: 'Ding', - }, - }; -} - /** * Translatable properties of things */ @@ -249,3 +214,63 @@ export interface SCThingTranslatablePropertyOrigin { */ name: string; } + +/** + * Meta information about things + */ +export class SCThingMeta implements SCMetaTranslations { + /** + * Set type definiton for singleton instance + */ + protected static _instance: SCThingMeta; + + /** + * Translations of fields + */ + fieldTranslations = { + de: { + alternateNames: 'alternative Namen', + description: 'Beschreibung', + image: 'Bild', + name: 'Name', + origin: 'Ursprung', + translations: 'Übersetzungen', + type: 'Typ', + uid: 'Identifikation', + url: 'URL', + }, + en: { + alternateNames: 'alternate names', + description: 'description', + image: 'image', + name: 'name', + origin: 'origin', + translations: 'translations', + type: 'type', + uid: 'identification', + url: 'URL', + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + type: 'Ding', + }, + en: { + type: 'Thing', + }, + }; + + /** + * Function to retrieve typed singleton instance + */ + public static getInstance(): T { + const typedThis = this as any as typeof SCThingMeta; + return (typedThis._instance || (typedThis._instance = new this())) as T; + } + + protected constructor() {} +} diff --git a/src/core/base/AcademicDegree.ts b/src/core/base/AcademicDegree.ts index f446677f..3465011b 100644 --- a/src/core/base/AcademicDegree.ts +++ b/src/core/base/AcademicDegree.ts @@ -14,6 +14,7 @@ */ import {SCThing} from '../Thing'; import {SCThingMeta} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * An academic degree without references @@ -40,19 +41,31 @@ export interface SCAcademicDegreeWithoutReferences extends SCThing { export interface SCAcademicDegree extends SCAcademicDegreeWithoutReferences { } -export class SCAcademicDegreeMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +/** + * Meta information about academic degrees + */ +export class SCAcademicDegreeMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ...SCThingMeta.getInstance().fieldTranslations.de, academicDegree: 'Hochschulgrad', academicDegreewithField: 'Abschlussbezeichnungen', academicDegreewithFieldShort: 'Abschlussbezeichnungen (kurz)', }, + en: { + ...SCThingMeta.getInstance().fieldTranslations.en, + }, }; - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, + /** + * Translations of values of fields + */ + fieldValueTranslations = { de: { + ...SCThingMeta.getInstance().fieldValueTranslations.de, academicDegree: { 'bachelor': 'Bachelor', 'diploma': 'Diplom', @@ -64,6 +77,9 @@ export class SCAcademicDegreeMeta extends SCThingMeta { 'state examination': 'Staatsexamen', }, }, + en: { + ...SCThingMeta.getInstance().fieldValueTranslations.en, + }, }; } diff --git a/src/core/base/AcademicTerm.ts b/src/core/base/AcademicTerm.ts index 41297513..988472a0 100644 --- a/src/core/base/AcademicTerm.ts +++ b/src/core/base/AcademicTerm.ts @@ -12,7 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing} from '../Thing'; +import {SCThing, SCThingMeta} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; /** @@ -44,3 +45,32 @@ export interface SCAcademicTermWithoutReferences extends SCThing { */ startDate: SCISO8601Date; } + +/** + * Meta information about academic terms + */ +export class SCAcademicTermWithoutReferencesMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/CreativeWork.ts b/src/core/base/CreativeWork.ts index a2be9cf5..b1df1cec 100644 --- a/src/core/base/CreativeWork.ts +++ b/src/core/base/CreativeWork.ts @@ -12,10 +12,10 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingTranslatableProperties} from '../Thing'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing'; import {SCOrganizationWithoutReferences} from '../things/Organization'; import {SCPersonWithoutReferences} from '../things/Person'; -import {SCLanguage, SCTranslations} from '../types/i18n'; +import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; import { SCAcademicPriceGroup, @@ -78,3 +78,32 @@ export interface SCCreativeWorkTranslatableProperties */ keywords?: string[]; } + +/** + * Meta information about creative works + */ +export class SCCreativeWorkMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/Event.ts b/src/core/base/Event.ts index 31cc3a35..80e12410 100644 --- a/src/core/base/Event.ts +++ b/src/core/base/Event.ts @@ -12,10 +12,11 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing} from '../Thing'; +import {SCThing, SCThingMeta} from '../Thing'; import {SCCatalogWithoutReferences} from '../things/Catalog'; import {SCPersonWithoutReferences} from '../things/Person'; import {SCSemesterWithoutReferences} from '../things/Semester'; +import {SCMetaTranslations} from '../types/i18n'; import {SCCreativeWorkWithoutReferences} from './CreativeWork'; /** @@ -68,3 +69,32 @@ export interface SCEvent extends SCEventWithoutReferences { */ performers?: SCPersonWithoutReferences[]; } + +/** + * Meta information about events + */ +export class SCEventMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/Place.ts b/src/core/base/Place.ts index d4b933ff..bc02d564 100644 --- a/src/core/base/Place.ts +++ b/src/core/base/Place.ts @@ -12,8 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing} from '../Thing'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing'; import {SCGeoInformation} from '../types/GeoInformation'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCPostalAddress} from '../types/PostalAddress'; /** @@ -49,3 +50,32 @@ export interface SCPlaceWithoutReferences extends SCThing { export interface SCPlaceWithoutReferencesTranslatableProperties extends SCThingTranslatableProperties { address?: SCPostalAddress; } + +/** + * Meta information about creative works + */ +export class SCPlaceWithoutReferencesMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/ThingInPlace.ts b/src/core/base/ThingInPlace.ts index 024359ad..ee891e8e 100644 --- a/src/core/base/ThingInPlace.ts +++ b/src/core/base/ThingInPlace.ts @@ -12,10 +12,42 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing} from '../Thing'; +import {SCThing, SCThingMeta} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; import {SCInPlace} from '../types/Places'; /** * A thing that is or happens in a place */ export interface SCThingInPlace extends SCThing, SCInPlace {} + +/** + * Meta information about thing in a place + */ +export class SCThingInPlaceMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + inPlace: 'Ort', + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + inPlace: 'location', + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/ThingThatAcceptsPayments.ts b/src/core/base/ThingThatAcceptsPayments.ts index 919b7c0d..67216a30 100644 --- a/src/core/base/ThingThatAcceptsPayments.ts +++ b/src/core/base/ThingThatAcceptsPayments.ts @@ -12,7 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing} from '../Thing'; +import {SCThing, SCThingMeta} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * Types of payment that are accepted at a place. @@ -31,3 +32,33 @@ export interface SCThingThatAcceptsPaymentsWithoutReferences extends SCThing { */ paymentsAccepted?: SCThingThatAcceptsPaymentsAcceptedPayments[]; } + +/** + * Meta information about a thing without references that accepts payments + */ +export class SCThingThatAcceptsPaymentsWithoutReferencesMeta extends SCThingMeta implements + SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; +} diff --git a/src/core/base/ThingWithCategories.ts b/src/core/base/ThingWithCategories.ts index f356e181..74376314 100644 --- a/src/core/base/ThingWithCategories.ts +++ b/src/core/base/ThingWithCategories.ts @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThing, SCThingTranslatableProperties} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCThing, SCThingMeta, SCThingTranslatableProperties} from '../Thing'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCMap} from '../types/Map'; /** @@ -84,3 +84,46 @@ export interface SCThingWithCategoriesSpecificValues { */ url?: string; } + +/** + * Meta information about a thing without references that accepts payments + */ +export class SCThingWithCategoriesWithoutReferencesMeta implements + SCMetaTranslations> { + + protected static _instance: SCThingMeta; + + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + }, + }; + + /** + * Function to retrieve typed singleton instance (including generics) + */ + public static getInstance(): SCThingWithCategoriesWithoutReferencesMeta { + return this._instance || (this._instance = new this()); + } + + protected constructor() { + } +} diff --git a/src/core/things/AcademicEvent.ts b/src/core/things/AcademicEvent.ts index 5ba3bc6b..09641e55 100644 --- a/src/core/things/AcademicEvent.ts +++ b/src/core/things/AcademicEvent.ts @@ -12,14 +12,15 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCEvent, SCEventWithoutReferences} from '../base/Event'; +import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event'; import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; /** * An academic event without references @@ -66,18 +67,6 @@ export interface SCAcademicEvent extends SCEvent, SCAcademicEventWithoutReferenc type: SCThingType.AcademicEvent; } -/** - * Event meta data - */ -export class SCAcademicEventMeta extends SCThingMeta { - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, - de: { - type: 'Event', - }, - }; -} - /** * Categories of academic events */ @@ -111,3 +100,42 @@ export interface SCAcademicEventTranslatableProperties */ originalCategory?: string; } + +/** + * Meta information about academic events + */ +export class SCAcademicEventMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCEventMeta.getInstance().fieldTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCEventMeta.getInstance().fieldTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCEventMeta.getInstance().fieldValueTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'akademische Veranstaltung', + }, + en: { + ... SCEventMeta.getInstance().fieldValueTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.AcademicEvent, + }, + }; +} diff --git a/src/core/things/Article.ts b/src/core/things/Article.ts index 73b7a407..35f95f32 100644 --- a/src/core/things/Article.ts +++ b/src/core/things/Article.ts @@ -14,6 +14,7 @@ */ import { SCCreativeWork, + SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, } from '../base/CreativeWork'; @@ -21,9 +22,10 @@ import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; /** * An article without references @@ -65,19 +67,6 @@ export interface SCArticle extends SCCreativeWork, SCArticleWithoutReferences { type: SCThingType.Article; } -/** - * Meta information about an article - */ -export class SCArticleMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, - de: { - articleBody: 'Artikeltext', - categories: 'Kategorien', - }, - }; -} - /** * Categories of articles */ @@ -93,3 +82,42 @@ export interface SCArticleTranslatableProperties */ articleBody?: string[]; } + +/** + * Meta information about an article + */ +export class SCArticleMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'Artikel', + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Article, + }, + }; +} diff --git a/src/core/things/Book.ts b/src/core/things/Book.ts index d559a062..d407fbb6 100644 --- a/src/core/things/Book.ts +++ b/src/core/things/Book.ts @@ -14,12 +14,13 @@ */ import { SCCreativeWork, + SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, } from '../base/CreativeWork'; import {SCThingWithCategoriesTranslatableProperties} from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCPersonWithoutReferences} from './Person'; /** @@ -74,20 +75,6 @@ export interface SCBook extends SCCreativeWork, SCBookWithoutReferences { type: SCThingType.Book; } -/** - * Meta information about a book - */ -export class SCBookMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, - de: { - bookEdition: 'Edition', - isbn: 'ISBN', - numberOfPages: 'Seitenanzahl', - }, - }; -} - /** * Translatable properties of a book */ @@ -98,3 +85,34 @@ export interface SCBookTranslatableFields */ bookEdition?: string; } + +/** + * Meta information about a book + */ +export class SCBookMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, + type: 'Buch', + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Book, + }, + }; +} diff --git a/src/core/things/Building.ts b/src/core/things/Building.ts index a56a4faa..4d5dfb3b 100644 --- a/src/core/things/Building.ts +++ b/src/core/things/Building.ts @@ -12,14 +12,19 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCPlaceWithoutReferences, SCPlaceWithoutReferencesTranslatableProperties} from '../base/Place'; +import { + SCPlaceWithoutReferences, + SCPlaceWithoutReferencesMeta, + SCPlaceWithoutReferencesTranslatableProperties, +} from '../base/Place'; import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; export type SCBuildingCategories = 'cafe' @@ -78,20 +83,35 @@ export interface SCBuildingTranslatableProperties floors?: string[]; } -/** - * Meta information about a place - */ -export class SCBuildingMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, + /** + * Meta information about a place + */ +export class SCBuildingMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, floors: 'Etagen', }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, }; - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, + /** + * Translations of values of fields + */ + fieldValueTranslations = { de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { 'cafe': 'Café', 'canteen': 'Kantine', @@ -104,5 +124,11 @@ export class SCBuildingMeta extends SCThingMeta { }, type: 'Gebäude', }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Building, + }, }; } diff --git a/src/core/things/Catalog.ts b/src/core/things/Catalog.ts index 03c6f3bc..1e4b0291 100644 --- a/src/core/things/Catalog.ts +++ b/src/core/things/Catalog.ts @@ -13,8 +13,13 @@ * this program. If not, see . */ import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm'; -import {SCThingWithCategoriesSpecificValues, SCThingWithCategoriesWithoutReferences} from '../base/ThingWithCategories'; +import { + SCThingWithCategoriesSpecificValues, + SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, +} from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * A catalog without references @@ -62,10 +67,39 @@ export interface SCCatalog extends SCCatalogWithoutReferences { type: SCThingType.Catalog; } -/** - * Catalog meta data - */ -export class SCCatalogMeta extends SCThingMeta { + /** + * Catalog meta data + */ +export class SCCatalogMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'Verzeichnis', + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Catalog, + }, + }; } /** diff --git a/src/core/things/CourseOfStudies.ts b/src/core/things/CourseOfStudies.ts index 2fadb569..0ff536c6 100644 --- a/src/core/things/CourseOfStudies.ts +++ b/src/core/things/CourseOfStudies.ts @@ -12,12 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCAcademicDegree} from '../base/AcademicDegree'; +import {SCAcademicDegree, SCAcademicDegreeMeta} from '../base/AcademicDegree'; import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCLanguage, SCTranslations} from '../types/i18n'; +import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCDateSeriesWithoutReferences} from './DateSeries'; import {SCOrganization} from './Organization'; @@ -92,22 +92,27 @@ export interface SCCourseOfStudiesTranslatableProperties } /** - * course of studies meta data + * Meta information about a course of studies */ -export class SCCourseOfStudiesMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { - academicDegree: 'Hochschulabschluss', - department: 'Fachbereich', - major: 'Studienfach', - modes: 'Studiengangsarten', - secretary: 'Sekretariat', + ... SCAcademicDegreeMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCAcademicDegreeMeta.getInstance().fieldTranslations.en, }, }; - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, + + /** + * Translations of values of fields + */ + fieldValueTranslations = { de: { + ... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de, modes: { combination: 'Kombinationsstudiengang', dual: 'Dualer Studiengang', @@ -116,6 +121,15 @@ export class SCCourseOfStudiesMeta extends SCThingMeta { }, type: 'Studiengang', }, + en: { + ... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en, + academicDegree: 'Hochschulabschluss', + department: 'Fachbereich', + major: 'Studienfach', + modes: 'Studiengangsarten', + secretary: 'Sekretariat', + type: SCThingType.CourseOfStudies, + }, }; } diff --git a/src/core/things/DateSeries.ts b/src/core/things/DateSeries.ts index 5eb15aee..1f3832f5 100644 --- a/src/core/things/DateSeries.ts +++ b/src/core/things/DateSeries.ts @@ -12,14 +12,14 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingInPlace} from '../base/ThingInPlace'; +import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; import { SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedTranslatableProperties, } from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCISO8601Date, SCISO8601Duration} from '../types/Time'; import {SCAcademicEventWithoutReferences} from './AcademicEvent'; import {SCPersonWithoutReferences} from './Person'; @@ -100,15 +100,35 @@ export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPl } /** - * Date series meta data + * Meta information about a date series */ -export class SCDateSeriesMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, dates: 'Einzeltermine', duration: 'Dauer', frequency: 'Wiederholung', + type: 'Wiederholungreihe', + }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.DateSeries, }, }; } diff --git a/src/core/things/Diff.ts b/src/core/things/Diff.ts index 16c0d50e..e2b9991f 100644 --- a/src/core/things/Diff.ts +++ b/src/core/things/Diff.ts @@ -15,6 +15,7 @@ import * as jsonpatch from 'json-patch'; import {SCThingsWithoutDiff} from '../Classes'; import {SCThing, SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; /** @@ -60,15 +61,40 @@ export interface SCDiff extends SCDiffWithoutReferences { } /** - * Diff meta data + * Meta information about a diff */ -export class SCDiffMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +export class SCDiffMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Set type definiton for singleton instance + */ + protected static _instance: SCThingMeta; + + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCThingMeta.getInstance().fieldTranslations.de, action: 'Aktion', changes: 'Änderungen', dateCreated: 'Erstellungsdatum', }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + type: 'Unterschied', + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Diff, + }, }; } diff --git a/src/core/things/Dish.ts b/src/core/things/Dish.ts index faf29cd4..2c458faf 100644 --- a/src/core/things/Dish.ts +++ b/src/core/things/Dish.ts @@ -21,9 +21,10 @@ import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; /** * A dish without references @@ -92,34 +93,7 @@ export interface SCDishTranslatableProperties /** * Characteristics of the dish */ - characteristics?: string[]; -} - -/** - * Dish meta data - */ -export class SCDishMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, - de: { - categories: 'Kategorien', - }, - }; - - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, - de: { - categories: { - appetizer: 'Vorspeise', - dessert: 'Nachtisch', - 'main dish': 'Hauptgericht', - salad: 'Salat', - 'side dish': 'Beilage', - soup: 'Suppe', - }, - type: 'Essen', - }, - }; + characteristics?: SCDishCharacteristic[]; } /** @@ -189,3 +163,46 @@ export interface SCNutritionInformation { */ sugarContent?: number; } + +/** + * Meta information about a dish + */ +export class SCDishMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + categories: { + appetizer: 'Vorspeise', + dessert: 'Nachtisch', + 'main dish': 'Hauptgericht', + salad: 'Salat', + 'side dish': 'Beilage', + soup: 'Suppe', + }, + type: 'Essen', + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Dish, + }, + }; +} diff --git a/src/core/things/Floor.ts b/src/core/things/Floor.ts index 13011313..3b131ce2 100644 --- a/src/core/things/Floor.ts +++ b/src/core/things/Floor.ts @@ -13,9 +13,9 @@ * this program. If not, see . */ import {Feature, FeatureCollection, GeometryObject, LineString} from 'geojson'; -import {SCThingInPlace} from '../base/ThingInPlace'; +import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCPointOfInterestWithoutReferences} from './PointOfInterest'; import {SCRoomWithoutReferences} from './Room'; @@ -61,12 +61,6 @@ export interface SCFloor extends SCFloorWithoutReferences, SCThingInPlace { type: SCThingType.Floor; } -/** - * Meta information about a floor - */ -export class SCFloorMeta extends SCThingMeta { -} - /** * A feature collection */ @@ -98,3 +92,34 @@ export interface SCFloorTranslatableProperties extends SCThingTranslatableProper */ floorName?: string; } + +/** + * Meta information about floors + */ +export class SCFloorMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, + type: 'Etage', + }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Floor, + }, + }; +} diff --git a/src/core/things/Message.ts b/src/core/things/Message.ts index 75f3ab76..5d105b0c 100644 --- a/src/core/things/Message.ts +++ b/src/core/things/Message.ts @@ -14,12 +14,13 @@ */ import { SCCreativeWork, + SCCreativeWorkMeta, SCCreativeWorkTranslatableProperties, SCCreativeWorkWithoutReferences, } from '../base/CreativeWork'; import {SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; /** @@ -69,12 +70,6 @@ export interface SCMessage extends SCCreativeWork, SCMessageWithoutReferences { type: SCThingType.Message; } -/** - * Meta information about a message - */ -export class SCMessageMeta extends SCThingMeta { -} - /** * Audiences for messages */ @@ -93,3 +88,34 @@ export interface SCMessageTranslatableProperties */ message?: string; } + +/** + * Meta information about messages + */ +export class SCMessageMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, + type: 'Nachricht', + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Message, + }, + }; +} diff --git a/src/core/things/Person.ts b/src/core/things/Person.ts index 89d32913..d4e3212c 100644 --- a/src/core/things/Person.ts +++ b/src/core/things/Person.ts @@ -13,7 +13,7 @@ * this program. If not, see . */ import {SCThing, SCThingMeta, SCThingType} from '../Thing'; -import {SCNationality} from '../types/i18n'; +import {SCMetaTranslations, SCNationality} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; import {SCBuildingWithoutReferences} from './Building'; import {SCOrganizationWithoutReferences} from './Organization'; @@ -129,7 +129,32 @@ export interface SCPerson extends SCPersonWithoutReferences { /** * Meta information about a person */ -export class SCPersonMeta extends SCThingMeta { +export class SCPersonMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + type: 'Person', + }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Person, + }, + }; } /** diff --git a/src/core/things/PointOfInterest.ts b/src/core/things/PointOfInterest.ts index 32e9ca2d..4745bbec 100644 --- a/src/core/things/PointOfInterest.ts +++ b/src/core/things/PointOfInterest.ts @@ -12,15 +12,16 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCPlaceWithoutReferences} from '../base/Place'; +import {SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place'; import {SCThingInPlace} from '../base/ThingInPlace'; import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; /** * A point of interest without references @@ -68,7 +69,42 @@ export type SCPointOfInterestCategories = | 'disabled access'; /** - * Meta data of a point of interest + * Meta information about points of interest */ -export class SCPointOfInterestMeta extends SCThingMeta { +export class SCPointOfInterestMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'Sonderziel', + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.PointOfInterest, + }, + }; } diff --git a/src/core/things/Room.ts b/src/core/things/Room.ts index 6f521070..4dfe50d0 100644 --- a/src/core/things/Room.ts +++ b/src/core/things/Room.ts @@ -12,16 +12,21 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCPlaceWithoutReferences} from '../base/Place'; -import {SCThingInPlace} from '../base/ThingInPlace'; -import {SCThingThatAcceptsPaymentsWithoutReferences} from '../base/ThingThatAcceptsPayments'; +import {SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from '../base/Place'; +import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; +import { + SCThingThatAcceptsPaymentsWithoutReferences, + SCThingThatAcceptsPaymentsWithoutReferencesMeta, +} from '../base/ThingThatAcceptsPayments'; import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; + import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCMap} from '../types/Map'; /** @@ -103,10 +108,37 @@ export interface SCRoomSpecificValues extends SCThingWithCategoriesSpecificValue /** * Meta information about a place */ -export class SCRoomMeta extends SCThingMeta { - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, +export class SCRoomMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de, + ... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + ... SCThingInPlaceMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en, + ... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ... SCThingInPlaceMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, categories: { 'cafe': 'Café', 'canteen': 'Kantine', @@ -122,6 +154,15 @@ export class SCRoomMeta extends SCThingMeta { 'student canteen': 'Mensa', 'student union': 'Studentenvereinigung', }, + type: 'Raum', + }, + en: { + ... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Room, }, }; } diff --git a/src/core/things/Semester.ts b/src/core/things/Semester.ts index e7a55d5b..e1b89b16 100644 --- a/src/core/things/Semester.ts +++ b/src/core/things/Semester.ts @@ -12,8 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCAcademicTermWithoutReferences} from '../base/AcademicTerm'; +import {SCAcademicTermWithoutReferences, SCAcademicTermWithoutReferencesMeta} from '../base/AcademicTerm'; import {SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * A semester without references @@ -45,17 +46,37 @@ export interface SCSemester extends SCSemesterWithoutReferences { } /** - * Semester meta data + * Meta information about a semester */ -export class SCSemesterMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +export class SCSemesterMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCAcademicTermWithoutReferencesMeta.getInstance().fieldTranslations.de, acronym: 'Abkürzung', endDate: 'Ende', eventsEndDate: 'Vorlesungsschluss', eventsStartDate: 'Vorlesungsbeginn', startDate: 'Beginn', }, + en: { + ... SCAcademicTermWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCAcademicTermWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'Semester', + }, + en: { + ... SCAcademicTermWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Semester, + }, }; } diff --git a/src/core/things/Setting.ts b/src/core/things/Setting.ts index aad2e66d..c9e1f59a 100644 --- a/src/core/things/Setting.ts +++ b/src/core/things/Setting.ts @@ -16,9 +16,10 @@ import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCTranslations} from '../types/i18n'; +import {SCMetaTranslations, SCTranslations} from '../types/i18n'; export type SCSettingCategories = string; @@ -123,10 +124,40 @@ export interface SCSettingValueTranslatableProperties extends SCThingWithCategor } /** - * Meta information about a setting + * Meta information about settings */ -export class SCSettingMeta extends SCThingMeta { - static fieldTranslations = { - ...SCThingMeta.fieldTranslations, +export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'Einstellung', + }, + en: { + // tslint:disable-next-line:max-line-length + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Setting, + }, }; } diff --git a/src/core/things/SportCourse.ts b/src/core/things/SportCourse.ts index 78e7208e..90069db3 100644 --- a/src/core/things/SportCourse.ts +++ b/src/core/things/SportCourse.ts @@ -12,8 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCEvent, SCEventWithoutReferences} from '../base/Event'; +import {SCEvent, SCEventMeta, SCEventWithoutReferences} from '../base/Event'; import {SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * A sport course without references @@ -38,13 +39,36 @@ export interface SCSportCourse extends SCEvent, SCSportCourseWithoutReferences { } /** - * Sport course meta data + * Meta information about a sport course */ -export class SCSportCourseMeta extends SCThingMeta { - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, +export class SCSportCourseMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCThingMeta.getInstance().fieldTranslations.de, + ... SCEventMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingMeta.getInstance().fieldTranslations.en, + ... SCEventMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingMeta.getInstance().fieldValueTranslations.de, + ... SCEventMeta.getInstance().fieldValueTranslations.de, type: 'Sportkurs', }, + en: { + ... SCThingMeta.getInstance().fieldValueTranslations.en, + ... SCEventMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.SportCourse, + }, }; } diff --git a/src/core/things/Ticket.ts b/src/core/things/Ticket.ts index f8494a99..48b4afb5 100644 --- a/src/core/things/Ticket.ts +++ b/src/core/things/Ticket.ts @@ -12,8 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingInPlace} from '../base/ThingInPlace'; +import {SCThingInPlace, SCThingInPlaceMeta} from '../base/ThingInPlace'; import {SCThing, SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; import {SCISO8601Duration} from '../types/Time'; /** @@ -56,11 +57,30 @@ export interface SCTicket extends SCTicketWithoutReferences, SCThingInPlace { /** * Meta information about a ticket */ -export class SCTicketMeta extends SCThingMeta { - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, +export class SCTicketMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, type: 'Ticket', }, + en: { + ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Ticket, + }, }; } diff --git a/src/core/things/ToDo.ts b/src/core/things/ToDo.ts index 874adb57..36dd4139 100644 --- a/src/core/things/ToDo.ts +++ b/src/core/things/ToDo.ts @@ -12,8 +12,12 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCThingWithCategoriesSpecificValues, SCThingWithCategoriesWithoutReferences} from '../base/ThingWithCategories'; +import { + SCThingWithCategoriesSpecificValues, + SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta} from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; import {SCISO8601Date} from '../types/Time'; /** @@ -60,7 +64,36 @@ export enum SCToDoPriority { } /** - * "To do" meta data + * Meta information about todo */ -export class SCToDoMeta extends SCThingMeta { +export class SCToDoMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + type: 'ToDo', + }, + en: { + ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.ToDo, + }, + }; } diff --git a/src/core/things/Tour.ts b/src/core/things/Tour.ts index 3d57ef40..253d0774 100644 --- a/src/core/things/Tour.ts +++ b/src/core/things/Tour.ts @@ -13,6 +13,7 @@ * this program. If not, see . */ import {SCThing, SCThingMeta, SCThingType} from '../Thing'; +import {SCMetaTranslations} from '../types/i18n'; /** * A tour without references @@ -49,7 +50,7 @@ export interface SCTour extends SCTourWithoutReferences { /** * Meta information about a tour */ -export class SCTourMeta extends SCThingMeta { +export class SCTourMeta extends SCThingMeta implements SCMetaTranslations { } /** diff --git a/src/core/things/Video.ts b/src/core/things/Video.ts index c777ac61..2e75a561 100644 --- a/src/core/things/Video.ts +++ b/src/core/things/Video.ts @@ -12,9 +12,9 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCCreativeWork, SCCreativeWorkWithoutReferences} from '../base/CreativeWork'; +import {SCCreativeWork, SCCreativeWorkMeta, SCCreativeWorkWithoutReferences} from '../base/CreativeWork'; import {SCThingMeta, SCThingType} from '../Thing'; -import {SCLanguage} from '../types/i18n'; +import {SCLanguage, SCMetaTranslations} from '../types/i18n'; import {SCISO8601Duration} from '../types/Time'; import {SCPersonWithoutReferences} from './Person'; @@ -114,19 +114,33 @@ export interface SCVideo extends SCCreativeWork, SCVideoWithoutReferences { type: SCThingType.Video; } -export class SCVideoMeta extends SCThingMeta { - static fieldValueTranslations = { - ...SCThingMeta.fieldValueTranslations, +/** + * Meta information about a video + */ +export class SCVideoMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { de: { - actors: 'Darsteller', - duration: 'Länge', - height: 'Höhe', - language: 'Sprache', - size: 'Größe', - sources: 'Quellen', - transcript: 'Abschrift', + ... SCCreativeWorkMeta.getInstance().fieldTranslations.de, + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldTranslations.en, + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de, type: 'Video', - width: 'Breite', + }, + en: { + ... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en, + type: SCThingType.Video, }, }; } diff --git a/src/core/types/i18n.ts b/src/core/types/i18n.ts index 665dd88b..843709ff 100644 --- a/src/core/types/i18n.ts +++ b/src/core/types/i18n.ts @@ -17,7 +17,7 @@ */ export interface SCLanguage { /** - * The Alpha-2 Code of the Language + * The two letter ISO 639-1 Code of the Language */ code: SCLanguageCode; @@ -28,8 +28,8 @@ export interface SCLanguage { } /** - * A list of possible languages - * + * A list of possible languages in english + * * @see https://en.wikipedia.org/wiki/ISO_639-1 */ export type SCLanguageName = @@ -220,7 +220,9 @@ export type SCLanguageName = | 'zulu'; /** - * A List of all possible Languages as Alpha-2 Codes + * A List of all possible Languages as ISO 639-1 Codes + * + * @see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes */ export type SCLanguageCode = 'aa' @@ -681,3 +683,37 @@ export interface SCTranslations { */ en?: T; } + +/** + * Type to represent requiredness of translation properties. + * Will be changed from RecursivePartial to RecursiveRequired in the future. + * (Source: https://stackoverflow.com/a/51365037) + */ +type RecursivePartial = { + [P in keyof T]?: + T[P] extends Array ? Array> : + T[P] extends object ? RecursivePartial : + T[P]; +}; + +/** + * Type to recursively map keys in to a string value (used for translation) + */ +type SCRequiredTranslationKeys = { + [key in keyof RecursivePartial]: string; +}; + +/** + * Type that allows mapping from available keys of SCTranslations to SCRequiredTranslationKeys + */ +type SCRequiredTranslation = { + [key in keyof SCTranslations]: SCRequiredTranslationKeys; +}; + +/** + * Interface to be implemented by all Meta classes + */ +export interface SCMetaTranslations { + fieldTranslations: SCRequiredTranslation; + fieldValueTranslations: any; +}