Skip to content

Commit a0627b0

Browse files
committed
Add Czech i18n support and several UI fixes
Detect Czech for project 704436 and use it as language fallback; switch many UI strings to conditional Czech/Slovak values (twentytwenty labels, FAQ show-more button, upsale texts, box config buttons, model info header, options label, etc.). Other fixes: use loose equality for 0 comparison in getButtonTypeClass to handle type mismatches; guard config popup so it's shown only when not "none"; default addPrice to 0 when absent to avoid NaN; always update displayed box price; minor text adjustments for button flows. These changes improve localization and robustness of product/upsale UI.
1 parent 5aae43e commit a0627b0

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

assets/js/components/creatButtons.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ let twoLayersProducts;
22
let boxsParameterIds;
33
let oneLayerProducts;
44

5+
const language = dataLayer[0].shoptet.projectId == 704436 ? "cs" : (shoptetData.language || dataLayer[0].shoptet.language);
6+
57
if ($(".type-product")[0]) {
68
twoLayersProducts = shoptetData.product.id == 601 || shoptetData.product.id == 604 || shoptetData.product.id == 607;
79
boxsParameterIds = [94, 97, 104];
@@ -38,7 +40,7 @@ const ButtonUtils = {
3840
* @returns {string} CSS class for button type
3941
*/
4042
getButtonTypeClass: (type, value) => {
41-
if (type === "config" && value === 0) return "none";
43+
if (type === "config" && value == 0) return "none";
4244
if (value === "89-2225") return "radio none";
4345
return type;
4446
},
@@ -114,7 +116,7 @@ export function createUpsaleButton(img, text, position, value, type, price, pref
114116
export function createOptions(position, orders) {
115117
let name = "";
116118
if (position == "box") {
117-
name = "Počet boxov";
119+
name = language === "cs" ? "Počet boxů" : "Počet boxov";
118120
} else if (position == "sizes") {
119121
name = "veľkosť";
120122
} else {
@@ -328,11 +330,11 @@ export function createBoxConfig() {
328330
}).appendTo(wrap);
329331
$("<div>", {
330332
class: "close-btn close bottom",
331-
text: "Nechci",
333+
text: language === "sk" ? "Nechcem" : "Nechci",
332334
}).appendTo(wrap);
333335
$("<div>", {
334336
class: "close-btn return",
335-
text: "potvrdit",
337+
text: language === "sk" ? "potvrdiť" : "potvrdit",
336338
}).appendTo(wrap);
337339
const configWrap = $("<div>", {
338340
class: "config-wrap",

assets/js/components/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export function intIndex() {
2+
const lang = dataLayer[0].shoptet.projectId == 704436 ? "cs" : (shoptetData.language || dataLayer[0].shoptet.language);
23
setTimeout(function () {
34
$(".twentytwenty-container").twentytwenty({
4-
before_label: "Potom",
5-
after_label: "Předtím",
5+
before_label: lang === "cs" ? "Potom" : "Po",
6+
after_label: lang === "cs" ? "Předtím" : "Predtým",
67
});
78
}, 1000);
89
$("svg.icon.icon-circle-button-right-clipped").remove();
@@ -504,20 +505,20 @@ function accordion() {
504505

505506
// Add show more button if not present
506507
if (!$(this).find(".faq-show-more").length) {
507-
const showMore = $(`<div class="faq-show-more"><button type="button">Zobrazit více</button></div>`);
508+
const showMore = $(`<div class="faq-show-more"><button type="button">${lang === "sk" ? "Zobraziť viac" : "Zobrazit více"}</button></div>`);
508509
$(this).append(showMore);
509510

510511
showMore.on("click", "button", function () {
511512
const hidden = $(this).closest(".faq").find(".accordion-hidden");
512513
if (hidden.length) {
513514
hidden.removeClass("accordion-hidden");
514-
$(this).text("Zobrazit méně");
515+
$(this).text(lang === "sk" ? "Zobraziť menej" : "Zobrazit méně");
515516
} else {
516517
const $accordions2 = $(this).closest(".faq").find(".accordion-wrapper");
517518
$accordions2.each(function (i) {
518519
if (i >= 4) $(this).addClass("accordion-hidden");
519520
});
520-
$(this).text("Zobrazit více");
521+
$(this).text(lang === "sk" ? "Zobraziť viac" : "Zobrazit více");
521522
// Ensure first hidden ones get closed
522523
$(this).closest(".faq").find(".panel").css("display", "none");
523524
$(this).closest(".faq").find(".accordion").removeClass("active");

assets/js/components/productPage.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let box1 = 94;
2626
let box2 = 97;
2727
let boxsPrice = [];
2828

29-
const language = shoptetData.language;
29+
const language = dataLayer[0].shoptet.projectId == 704436 ? "cs" : (shoptetData.language || dataLayer[0].shoptet.language);
3030
if (dataLayer[0].shoptet.projectId == "581408") {
3131
koberce = 60;
3232
boxy = 63;
@@ -508,7 +508,7 @@ function priplatky(setupData, texts) {
508508
// Určí text tlačítka podle pozice
509509
const isLast = index === allWraps.length - 1;
510510
let buttonText = isLast ? "Dokončit konfiguraci" : "Přejít k dalšímu kroku";
511-
if (dataLayer[0].shoptet.language == "sk") {
511+
if (language === "sk") {
512512
buttonText = isLast ? "Dokončiť konfiguráciu" : "Prejsť k ďalšiemu kroku";
513513
}
514514
const buttonClass = isLast ? "next-step-button finish-button" : "next-step-button";
@@ -534,7 +534,10 @@ function priplatky(setupData, texts) {
534534
const isLast = index === allWraps.length - 1;
535535
console.log(index);
536536
console.log(isLast);
537-
const buttonText = isLast ? "Dokončit konfiguraci" : "Přejít k dalšímu kroku";
537+
let buttonText = isLast ? "Dokončit konfiguraci" : "Přejít k dalšímu kroku";
538+
if (language === "sk") {
539+
buttonText = isLast ? "Dokončiť konfiguráciu" : "Prejsť k ďalšiemu kroku";
540+
}
538541

539542
// Aktualizuj text a třídu
540543
$button.text(buttonText);
@@ -927,7 +930,7 @@ function createModelInfo() {
927930

928931
if ($(".model-info")[0]) return;
929932
const infoWrap = $("<div>").addClass("model-info").prependTo(".col-xs-12.col-lg-6.p-info-wrapper");
930-
$("<div>").addClass("header-info").text("Garancia kompatibility s Vaším vozidlom").appendTo(infoWrap);
933+
$("<div>").addClass("header-info").text(language === "cs" ? "Záruka kompatibility s Vaším vozidlem" : "Garancia kompatibility s Vaším vozidlom").appendTo(infoWrap);
931934
$("<div>").addClass("model-text").text(model).appendTo(infoWrap);
932935

933936
// $("<div>").addClass("setup-model").text("Upraviť").appendTo(infoWrap);
@@ -1084,19 +1087,23 @@ function createUpsalePopup() {
10841087
$(".ti-widget-container").addClass("upsale");
10851088
$("<div>", {
10861089
class: "h2",
1087-
text: "Iba teraz za zvýhodnenú cenu!",
1090+
text: language === "cs" ? "Jen teď za zvýhodněnou cenu!" : "Iba teraz za zvýhodnenú cenu!",
10881091
}).appendTo(".ti-widget-container");
10891092
$("<div>", {
10901093
class: "description",
1091-
text: " Doplňte svoju objednávku o kufrové koberčeky alebo úložné boxy s výraznou zľavou. Ponuka platí len chvíľu!",
1094+
text: language === "cs"
1095+
? "Doplňte svou objednávku o kufřové koberce nebo úložné boxy s výraznou slevou. Nabídka platí jen chvíli!"
1096+
: "Doplňte svoju objednávku o kufrové koberčeky alebo úložné boxy s výraznou zľavou. Ponuka platí len chvíľu!",
10921097
}).appendTo(".ti-widget-container");
10931098
$("<div>", {
10941099
class: "button btn open-upsale",
1095-
text: "Využiť zvýhodnenú ponuku!",
1100+
text: language === "cs" ? "Využít zvýhodněnou nabídku!" : "Využiť zvýhodnenú ponuku!",
10961101
}).appendTo(".ti-widget-container");
10971102
$("<div>", {
10981103
class: "prefix",
1099-
text: "Len počas tejto objednávky môžete získať koberčeky do kufra alebo úložné boxy za extrémne zvýhodnenú cenu. Chráňte a organizujte svoj kufor so štýlom!",
1104+
text: language === "cs"
1105+
? "Jen během této objednávky můžete získat koberce do kufru nebo úložné boxy za extrémně zvýhodněnou cenu. Chraňte a organizujte svůj kufr se stylem!"
1106+
: "Len počas tejto objednávky môžete získať koberčeky do kufra alebo úložné boxy za extrémne zvýhodnenú cenu. Chráňte a organizujte svoj kufor so štýlom!",
11001107
}).appendTo(".ti-widget-container");
11011108

11021109
$(".button.btn.open-upsale").on("click", function () {
@@ -1168,8 +1175,8 @@ function updateUpsale($this, event) {
11681175
$("select.surcharge-parameter.parameter-id-" + value[0]).val(value[1]);
11691176
}
11701177

1171-
// Pokud je config, zobrazím konfiguraci
1172-
if ($($this).hasClass("config")) {
1178+
// Pokud je config a ne none, zobrazím konfiguraci
1179+
if ($($this).hasClass("config") && !$($this).hasClass("none")) {
11731180
$($this).parents(".upsale-Banner").addClass("showConf");
11741181
}
11751182

@@ -1299,15 +1306,10 @@ function updateUpsale($this, event) {
12991306
function updateBoxPrice() {
13001307
$(".box-config .parameter-wrap").each(function () {
13011308
const price = Number($(this).find(".price.price-standart").attr("data-price"));
1302-
const addPrice = Number($(this).find(".button.option-button.text.active .price").attr("data-price"));
1309+
const addPrice = Number($(this).find(".button.option-button.text.active .price").attr("data-price") || 0);
13031310
console.log(price, addPrice);
13041311

1305-
if (addPrice) {
1306-
$(this)
1307-
.find(".price.price-standart")
1308-
1309-
.text(NumToPrice(price + addPrice));
1310-
}
1312+
$(this).find(".price.price-standart").text(NumToPrice(price + addPrice));
13111313
});
13121314
}
13131315

0 commit comments

Comments
 (0)