Skip to content

Commit 8537be0

Browse files
feat: add translation promo badge (#922)
* refactor: solve ts errors * feat: implement translation for variants * refactor: size computed * chore: add changeset
1 parent 9d0d13a commit 8537be0

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.changeset/spotty-hornets-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@shopware-ag/meteor-component-library": patch
3+
---
4+
5+
feat: add translation to promo badge

packages/component-library/src/components/feedback-indicator/mt-promo-badge/mt-promo-badge.vue

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<script setup lang="ts">
1010
import { computed } from "vue";
11+
import { useI18n } from "vue-i18n";
1112
import MtBadge from "../mt-badge/mt-badge.vue";
1213
1314
const props = withDefaults(
@@ -21,17 +22,40 @@ const props = withDefaults(
2122
},
2223
);
2324
25+
const { t } = useI18n({
26+
messages: {
27+
en: {
28+
"mt-promo-badge": {
29+
new: "New",
30+
beta: "Beta",
31+
shopwareAi: "Shopware AI",
32+
},
33+
},
34+
de: {
35+
"mt-promo-badge": {
36+
new: "Neu",
37+
beta: "Beta",
38+
shopwareAi: "Shopware AI",
39+
},
40+
},
41+
},
42+
});
43+
2444
const size = computed(() => {
25-
const normalizedSize = String(props.size ?? "s").toLowerCase();
26-
return ["s", "m", "l"].includes(normalizedSize) ? normalizedSize : "s";
45+
const n = String(props.size ?? "s").toLowerCase();
46+
return n === "s" ? "s" : n === "m" ? "m" : n === "l" ? "l" : "s";
2747
});
2848
2949
const badgeVariant = computed(() =>
3050
props.variant === "shopware-ai" ? "neutral" : props.variant === "beta" ? "info" : "positive",
3151
);
3252
3353
const promoText = computed(() =>
34-
props.variant === "shopware-ai" ? "Shopware AI" : props.variant === "new" ? "New" : "Beta",
54+
props.variant === "shopware-ai"
55+
? t("mt-promo-badge.shopwareAi")
56+
: props.variant === "new"
57+
? t("mt-promo-badge.new")
58+
: t("mt-promo-badge.beta"),
3559
);
3660
3761
const badgeIcon = computed(() =>

0 commit comments

Comments
 (0)