feat: add SCThingTranslator class. move functionality accordingly

This commit is contained in:
Rainer Killinger
2018-12-03 14:58:46 +01:00
committed by Karl-Philipp Wulfert
parent 797e5ca9de
commit 90e3d22399
9 changed files with 376 additions and 89 deletions

View File

@@ -12,7 +12,7 @@
* 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, SCPlaceWithoutReferencesTranslatableProperties} from '../base/Place';
import {
SCThingWithCategoriesSpecificValues,
SCThingWithCategoriesTranslatableProperties,
@@ -48,7 +48,7 @@ export interface SCBuildingWithoutReferences
/**
* Translated fields of a building
*/
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
translations?: SCTranslations<SCBuildingTranslatableProperties>;
/**
* Type of the building
@@ -62,16 +62,33 @@ export interface SCBuildingWithoutReferences
* @validatable
*/
export interface SCBuilding extends SCBuildingWithoutReferences {
/**
* Translated fields of a building
*/
translations?: SCTranslations<SCBuildingTranslatableProperties>;
/**
* Type of the building
*/
type: SCThingType.Building;
}
export interface SCBuildingTranslatableProperties
extends SCPlaceWithoutReferencesTranslatableProperties, SCThingWithCategoriesTranslatableProperties {
floors?: string[];
}
/**
* Meta information about a place
*/
export class SCBuildingMeta extends SCThingMeta {
static fieldTranslations = {
...SCThingMeta.fieldTranslations,
de: {
floors: 'Etagen',
},
};
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
de: {
@@ -85,6 +102,7 @@ export class SCBuildingMeta extends SCThingMeta {
'restroom': 'Toilette',
'student canteen': 'Mensa',
},
type: 'Gebäude',
},
};
}

View File

@@ -88,8 +88,12 @@ export interface SCDish extends SCDishWithoutReferences {
}
export interface SCDishTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties,
SCThingThatCanBeOfferedTranslatableProperties {}
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/**
* Characteristics of the dish
*/
characteristics?: string[];
}
/**
* Dish meta data
@@ -101,6 +105,21 @@ export class SCDishMeta extends SCThingMeta {
categories: 'Kategorien',
},
};
static fieldValueTranslations = {
...SCThingMeta.fieldValueTranslations,
de: {
categories: {
appetizer: 'Vorspeise',
dessert: 'Nachtisch',
'main dish': 'Hauptgericht',
salad: 'Salat',
'side dish': 'Beilage',
soup: 'Suppe',
},
type: 'Essen',
},
};
}
/**