diff --git a/src/components/entity/CredentialItem.vue b/src/components/entity/CredentialItem.vue index a87daa9..afc2657 100644 --- a/src/components/entity/CredentialItem.vue +++ b/src/components/entity/CredentialItem.vue @@ -17,7 +17,13 @@

{{ credTitle["key"] }}: - {{ translateValue(credTitle["accessor"], credTitle["value"]) }} + {{ + translateValue( + credTitle["accessor"], + credTitle["value"], + entityType + ) + }}

@@ -51,7 +57,7 @@ >
{{ attr["key"] }}
- {{ translateValue(attr["accessor"], attr["value"]) }} + {{ translateValue(attr["accessor"], attr["value"], entityType) }}
@@ -87,11 +93,12 @@ import { mapGetters } from "vuex"; import { ICredentialDisplayType } from "@/interfaces/api/v4/credential.interface"; import { selectFirstAttrItem } from "@/utils/attribute"; import i18n from "@/i18n/index"; +import { $translate } from "@/i18n/translate"; import { dateFilter } from "@/filters/date.filter"; import { IFormattedTopic } from "@/interfaces/api/v2/topic.interface"; import { ICredentialType } from "@/interfaces/api/v2/credential-type.interface"; import { TranslateResult } from "vue-i18n"; -import { isExpired } from "@/utils/entity"; +import { isExpired, toTranslationFormat } from "@/utils/entity"; @Component({ computed: { @@ -106,6 +113,7 @@ import { isExpired } from "@/utils/entity"; export default class CredentialItem extends Vue { @Prop({}) cred!: ICredentialDisplayType; + @Prop({ default: "" }) entityType!: string; @Prop({ default: "" }) authority!: string; @Prop({ default: "" }) authorityLink!: string; @Prop({ default: "" }) effectiveDate!: string; @@ -120,6 +128,8 @@ export default class CredentialItem extends Vue { credentialTypes!: ICredentialType[]; isExpired = isExpired; + toTranslationFormate = toTranslationFormat; + $translate = $translate; get getAuthorityLink(): string | URL { return this.cred ? this.cred.authorityLink : this.authorityLink; @@ -175,9 +185,16 @@ export default class CredentialItem extends Vue { } } - translateValue(accessor: string, val: string): string | TranslateResult { - const res = this.$t(accessor + "." + val); - if (res != accessor + "." + val) { + translateValue( + accessor: string, + val: string, + entityType: string + ): string | TranslateResult { + // need entity type to properly translate due to LEAR entries + const res = $translate( + toTranslationFormat(accessor + "." + val, entityType) + ); + if (res != toTranslationFormat(accessor + "." + val, entityType)) { return res; } return val; diff --git a/src/components/entity/EntityResult.vue b/src/components/entity/EntityResult.vue index e4bc0d7..536fc23 100644 --- a/src/components/entity/EntityResult.vue +++ b/src/components/entity/EntityResult.vue @@ -38,6 +38,7 @@