Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #996 from Shinsina/leaders-translations
Browse files Browse the repository at this point in the history
Leaders Vue component translation support
  • Loading branch information
B77Mills authored Oct 29, 2024
2 parents 6b7480f + d005278 commit d7d0a98
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@
type="accent"
@click="emitWebsiteClick"
>
Visit Site
{{ translate("visitSiteLabel") }}
</button-link>
<button-link
:href="profileHref"
:block="true"
@click="emitProfileClick('View Profile Button', ...arguments)"
>
View Profile
{{ translate("viewProfileLabel") }}
</button-link>
</div>
</div>
</template>

<script>
import i18n from '../../../utils/i18n-vue';
import ButtonLink from '../../common/button-link.vue';
import CommonLink from '../../common/link.vue';
Expand All @@ -57,6 +58,10 @@ export default {
type: String,
default: null,
},
lang: {
type: String,
default: 'en',
},
logoSrc: {
type: String,
default: null,
Expand All @@ -76,6 +81,9 @@ export default {
emitProfileClick(sourceLabel, data, event) {
this.$emit('profile-click', { sourceLabel, ...data }, event);
},
translate(key) {
return i18n(this.lang, key);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</template>

<script>
import i18n from '../../../utils/i18n-vue';
import CommonLink from '../../common/link.vue';
export default {
Expand All @@ -23,6 +24,10 @@ export default {
type: String,
default: null,
},
lang: {
type: String,
default: 'en',
},
prefix: {
type: String,
default: 'View more',
Expand All @@ -31,7 +36,12 @@ export default {
computed: {
value() {
const { prefix, label } = this;
const { prefix, label, lang } = this;
if (this.lang !== 'en') {
const translatedPrefix = i18n(lang, prefix.toLowerCase());
const translatedLabel = i18n(lang, label.toLowerCase());
return [translatedPrefix, translatedLabel].filter((v) => v).join(' ');
}
return [prefix, label].filter((v) => v).join(' ');
},
},
Expand Down
24 changes: 21 additions & 3 deletions packages/leaders-program/src/components/card/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:logo-src="logo.src"
:profile-href="profileHref"
:company-href="company.website"
:lang="lang"
@profile-click="handleProfileClick"
@website-click="handleWebsiteClick"
/>
Expand All @@ -32,13 +33,14 @@
<div v-if="displayBody" class="leaders-card__body">
<content-deck :value="promotions" :limit="4" :item-modifiers="['promo']">
<template #header-left>
{{ featuredProductLabel }}
{{ finalizedFeaturedProductsLabel }}
</template>
<template #header-right>
<view-more
label="products"
:href="productsHref"
target="_blank"
:lang="lang"
@click="handleAllProductsClick"
/>
</template>
Expand All @@ -61,13 +63,14 @@
:item-modifiers="['video']"
>
<template #header-left>
Featured Videos
{{ translate("featuredVideosLabel") }}
</template>
<template #header-right>
<view-more
label="videos"
:href="youtubeHref"
target="_blank"
:lang="lang"
@click="handleAllVideosClick"
/>
</template>
Expand All @@ -88,13 +91,14 @@
:item-modifiers="['video']"
>
<template #header-left>
Featured Videos
{{ translate("featuredVideosLabel") }}
</template>
<template #header-right>
<view-more
label="videos"
:href="profileHref"
target="_blank"
:lang="lang"
@click="handleAllVideosClick"
/>
</template>
Expand Down Expand Up @@ -123,6 +127,7 @@ import VideoCard from './blocks/video-card.vue';
import ViewMore from './blocks/view-more.vue';
import getAsObject from '../../utils/get-as-object';
import getEdgeNodes from '../../utils/get-edge-nodes';
import i18n from '../../utils/i18n-vue';
export default {
components: {
Expand Down Expand Up @@ -152,6 +157,10 @@ export default {
type: Boolean,
default: true,
},
lang: {
type: String,
default: 'en',
},
},
computed: {
Expand Down Expand Up @@ -197,6 +206,12 @@ export default {
if (this.isActive) classes.push(`${blockName}--active`);
return classes;
},
finalizedFeaturedProductsLabel() {
if (this.lang !== 'en') {
return i18n(this.lang, 'featuredProductsLabel');
}
return this.featuredProductLabel || i18n(this.lang, 'featuredProductsLabel');
},
},
watch: {
Expand Down Expand Up @@ -261,6 +276,9 @@ export default {
date: Date.now(),
}, event);
},
translate(key) {
return i18n(this.lang, key);
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:feature-youtube-videos="featureYoutubeVideos"
:collapse-empty-categories="collapseEmptyCategories"
:icon-style="iconStyle"
:lang="lang"
@action="emitAction"
/>
</leaders-columns>
Expand All @@ -55,6 +56,7 @@
:promotion-limit="promotionLimit"
:video-limit="videoLimit"
:icon-style="iconStyle"
:lang="lang"
@action="emitAction"
/>
</leaders-columns>
Expand Down Expand Up @@ -127,6 +129,10 @@ export default {
type: Boolean,
default: false,
},
lang: {
type: String,
default: 'en',
},
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
:is-active="isActive"
:featured-product-label="featuredProductLabel"
:feature-youtube-videos="featureYoutubeVideos"
:lang="lang"
@action="emitAction"
/>
</template>
Expand Down Expand Up @@ -128,6 +129,10 @@ export default {
default: 'plus-minus',
validator: (v) => ['plus-minus', 'chevron'].includes(v),
},
lang: {
type: String,
default: 'en',
},
},
data: () => ({
Expand Down
5 changes: 5 additions & 0 deletions packages/leaders-program/src/components/leaders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
:feature-youtube-videos="featureYoutubeVideos"
:collapse-empty-categories="collapseEmptyCategories"
:icon-style="iconStyle"
:lang="lang"
@action="emitAction"
/>
</div>
Expand Down Expand Up @@ -203,6 +204,10 @@ export default {
default: 'plus-minus',
validator: (v) => ['plus-minus', 'chevron'].includes(v),
},
lang: {
type: String,
default: 'en',
},
},
data: () => ({
Expand Down
20 changes: 20 additions & 0 deletions packages/leaders-program/src/utils/translations-vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
en: {
visitSiteLabel: 'Visit Site',
viewProfileLabel: 'View Profile',
featuredVideosLabel: 'Featured Videos',
featuredProductsLabel: 'Featured Products',
'view more': 'View more',
videos: 'videos',
products: 'products',
},
es: {
visitSiteLabel: 'Visite el sitio web',
viewProfileLabel: 'Vea el perfil',
featuredVideosLabel: 'Videos destacados',
featuredProductsLabel: 'Productos destacados',
'view more': 'Vea más',
videos: 'videos',
products: 'productos',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</template>

<script>
import i18n from '../i18n-vue';
import i18n from '@parameter1/base-cms-leaders-program/src/utils/i18n-vue';
export default {
props: {
Expand Down
8 changes: 0 additions & 8 deletions packages/marko-web-leaders/translations-vue.js

This file was deleted.

0 comments on commit d7d0a98

Please sign in to comment.