mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
refactor: change meta class structure to include types.
Introduce requiredness of translations via implemented interface.
This commit is contained in:
committed by
Karl-Philipp Wulfert
parent
90e3d22399
commit
62975b9ded
@@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user