mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +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,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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user