mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-01 02:52:51 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f96bc8569 | ||
|
|
9ce4026b1a | ||
|
|
e434b2d26e | ||
|
|
fe7f1a53ae | ||
|
|
907d61b5d2 | ||
|
|
5fb9755841 |
@@ -37,7 +37,7 @@ audit:
|
||||
scheduled-audit:
|
||||
stage: audit
|
||||
script:
|
||||
- npm audit
|
||||
- npm audit --audit-level=high
|
||||
only:
|
||||
- schedules
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# [0.35.0](https://gitlab.com/openstapps/core/compare/v0.34.0...v0.35.0) (2020-05-13)
|
||||
|
||||
|
||||
|
||||
# [0.34.0](https://gitlab.com/openstapps/core/compare/v0.33.0...v0.34.0) (2020-04-21)
|
||||
|
||||
|
||||
|
||||
1337
package-lock.json
generated
1337
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/core",
|
||||
"version": "0.35.0",
|
||||
"version": "0.36.0",
|
||||
"description": "StAppsCore - Generalized model of data",
|
||||
"keywords": [
|
||||
"Model",
|
||||
|
||||
@@ -229,6 +229,26 @@ export class SCThingTranslator {
|
||||
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SCThingType this function will translate it
|
||||
*
|
||||
* @param type The type that will be translated
|
||||
* @param language The language the type will be translated to
|
||||
* @returns Known translation of type parameter
|
||||
*/
|
||||
public translatedThingType<T extends unknown>(type: SCThingType,
|
||||
language?: keyof SCTranslations<T>): string {
|
||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||
const metaClass = this.getMetaClassInstance(type);
|
||||
|
||||
if (typeof metaClass.fieldValueTranslations[targetLanguage] !== 'undefined' &&
|
||||
typeof metaClass.fieldValueTranslations[targetLanguage].type !== 'undefined') {
|
||||
return metaClass.fieldValueTranslations[targetLanguage].type as string ;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively translates the given object in-place
|
||||
* Translated values overwrite current values (destructive)
|
||||
|
||||
@@ -263,6 +263,16 @@ export class MetaTranslationSpec {
|
||||
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
||||
}
|
||||
|
||||
@test
|
||||
public retrieveTranslatedThingType() {
|
||||
const dishTypeDE = translator.translatedThingType(dish.type);
|
||||
const dishTypeEN = translator.translatedThingType(dish.type, 'en');
|
||||
const dishTypeBASE = translatorWithFallback.translatedThingType(dish.type);
|
||||
expect(dishTypeDE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.de.type);
|
||||
expect(dishTypeEN).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||
expect(dishTypeBASE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||
}
|
||||
|
||||
@test
|
||||
public thingWithoutMetaClass() {
|
||||
const dishCopy = clone(dish);
|
||||
|
||||
Reference in New Issue
Block a user