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,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,
},
};
}