refactor: change meta class structure to include types.

Introduce requiredness of translations via implemented interface.
This commit is contained in:
Rainer Killinger
2019-02-06 14:21:46 +01:00
committed by Karl-Philipp Wulfert
parent 90e3d22399
commit 62975b9ded
32 changed files with 1060 additions and 246 deletions

View File

@@ -12,11 +12,13 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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

View File

@@ -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<SCThing> {
/**
* 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 extends SCThingMeta>(): T {
const typedThis = this as any as typeof SCThingMeta;
return (typedThis._instance || (typedThis._instance = new this())) as T;
}
protected constructor() {}
}

View File

@@ -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<SCAcademicDegree> {
/**
* 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,
},
};
}

View File

@@ -12,7 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCThing> {
/**
* 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,
},
};
}

View File

@@ -12,10 +12,10 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCCreativeWork> {
/**
* 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,
},
};
}

View File

@@ -12,10 +12,11 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCEvent> {
/**
* 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,
},
};
}

View File

@@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCPlaceWithoutReferences> {
/**
* 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,
},
};
}

View File

@@ -12,10 +12,42 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCThingInPlace> {
/**
* 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,
},
};
}

View File

@@ -12,7 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCThingThatAcceptsPaymentsWithoutReferences> {
/**
* 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,
},
};
}

View File

@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<T, U> implements
SCMetaTranslations<SCThingWithCategoriesWithoutReferences<T, U>> {
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<T, U>(): SCThingWithCategoriesWithoutReferencesMeta<T, U> {
return this._instance || (this._instance = new this<T, U>());
}
protected constructor() {
}
}

View File

@@ -12,14 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCAcademicEvent> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCEventMeta.getInstance().fieldTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCEventMeta.getInstance().fieldTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCEventMeta.getInstance().fieldValueTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'akademische Veranstaltung',
},
en: {
... SCEventMeta.getInstance().fieldValueTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCAcademicEventCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.AcademicEvent,
},
};
}

View File

@@ -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<SCArticle> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCCreativeWorkMeta.getInstance().fieldTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'Artikel',
},
en: {
... SCCreativeWorkMeta.getInstance().fieldValueTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCArticleCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Article,
},
};
}

View File

@@ -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<SCBook> {
/**
* 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,
},
};
}

View File

@@ -12,14 +12,19 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCBuilding> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de,
floors: 'Etagen',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en,
},
};
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().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<SCBuildingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Building,
},
};
}

View File

@@ -13,8 +13,13 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCCatalog> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'Verzeichnis',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCCatalogCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Catalog,
},
};
}
/**

View File

@@ -12,12 +12,12 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCCourseOfStudies> {
/**
* 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,
},
};
}

View File

@@ -12,14 +12,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCDateSeries> {
/**
* 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,
},
};
}

View File

@@ -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<SCDiff> {
/**
* 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,
},
};
}

View File

@@ -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<SCDish> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
categories: {
appetizer: 'Vorspeise',
dessert: 'Nachtisch',
'main dish': 'Hauptgericht',
salad: 'Salat',
'side dish': 'Beilage',
soup: 'Suppe',
},
type: 'Essen',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Dish,
},
};
}

View File

@@ -13,9 +13,9 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCFloor> {
/**
* 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,
},
};
}

View File

@@ -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<SCMessage> {
/**
* 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,
},
};
}

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCPerson> {
/**
* 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,
},
};
}
/**

View File

@@ -12,15 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCPointOfInterest> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de,
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
type: 'Sonderziel',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCPointOfInterestCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.PointOfInterest,
},
};
}

View File

@@ -12,16 +12,21 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCRoom> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.de,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.de,
... SCThingInPlaceMeta.getInstance().fieldTranslations.de,
},
en: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldTranslations.en,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldTranslations.en,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().fieldTranslations.en,
... SCThingInPlaceMeta.getInstance().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCPlaceWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
... SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance().fieldValueTranslations.de,
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
SCRoomSpecificValues>().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<SCRoomCategories,
SCRoomSpecificValues>().fieldValueTranslations.en,
... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en,
type: SCThingType.Room,
},
};
}

View File

@@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCSemester> {
/**
* 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,
},
};
}

View File

@@ -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<SCSetting> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'Einstellung',
},
en: {
// tslint:disable-next-line:max-line-length
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.Setting,
},
};
}

View File

@@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCSportCourse> {
/**
* 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,
},
};
}

View File

@@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCTicket> {
/**
* 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,
},
};
}

View File

@@ -12,8 +12,12 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCToDo> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
type: 'ToDo',
},
en: {
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<string,
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
type: SCThingType.ToDo,
},
};
}

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCTour> {
}
/**

View File

@@ -12,9 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<SCVideo> {
/**
* 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,
},
};
}

View File

@@ -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<T> {
*/
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<T> = {
[P in keyof T]?:
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
T[P] extends object ? RecursivePartial<T[P]> :
T[P];
};
/**
* Type to recursively map keys in <T> to a string value (used for translation)
*/
type SCRequiredTranslationKeys<T> = {
[key in keyof RecursivePartial<T>]: string;
};
/**
* Type that allows mapping from available keys of SCTranslations to SCRequiredTranslationKeys
*/
type SCRequiredTranslation<T> = {
[key in keyof SCTranslations<T>]: SCRequiredTranslationKeys<T>;
};
/**
* Interface to be implemented by all Meta classes
*/
export interface SCMetaTranslations<T> {
fieldTranslations: SCRequiredTranslation<T>;
fieldValueTranslations: any;
}