Browse Source

feat(i18n): localize shared page JS UI strings via t()

Co-authored-by: Cursor <cursoragent@cursor.com>
master
peijunlei 2 weeks ago
parent
commit
2af59c3c85
  1. 2
      public/themes/dist_static/static/js/about.js
  2. 2
      public/themes/dist_static/static/js/announce.js
  3. 2
      public/themes/dist_static/static/js/category.js
  4. 6
      public/themes/dist_static/static/js/search.js
  5. 6
      public/themes/dist_static/static/js/video.js

2
public/themes/dist_static/static/js/about.js

@ -71,7 +71,7 @@ function initHonorsToggle() {
btn.addEventListener("click", () => {
const expanded = list.classList.toggle("is-expanded");
btn.classList.toggle("is-expanded", expanded);
btn.querySelector("span").textContent = expanded ? "收起" : "展开更多";
btn.querySelector("span").textContent = expanded ? t("about.collapse") : t("about.expand_more");
});
}
$(function() {

2
public/themes/dist_static/static/js/announce.js

@ -31,7 +31,7 @@ function initFilterDropdown() {
const $dropdown = $item.closest("[data-filter-dropdown]");
const $btn = $dropdown.prev("[data-filter-trigger]");
if ($item.is("[data-filter-clear]")) {
$btn.find("span").text("按产品筛选");
$btn.find("span").text(t("filter.by_product"));
$btn.removeClass("is-selected");
$dropdown.find(".is-active").removeClass("is-active");
$item.addClass("is-active");

2
public/themes/dist_static/static/js/category.js

@ -83,7 +83,7 @@ function updateBreadcrumb(state) {
const name = getCategoryName(state.categoryId);
const breadcrumb = document.querySelector("[data-breadcrumb-current]");
if (breadcrumb && name) breadcrumb.textContent = name;
if (name) document.title = `${name} - 睿能科技`;
if (name) document.title = `${name} - ${t("brand.short")}`;
}
function updateView(state) {
updateSidebar(state);

6
public/themes/dist_static/static/js/search.js

@ -31,7 +31,7 @@ function initVideoModal() {
const openModal = (src, title) => {
if (!src) return;
lastFocus = document.activeElement;
titleEl.textContent = title || "视频播放";
titleEl.textContent = title || t("video.play");
if (video.getAttribute("src") !== src) video.src = src;
modal.hidden = false;
document.body.style.overflow = "hidden";
@ -52,8 +52,8 @@ function initVideoModal() {
card.addEventListener("click", () => {
const title =
card.closest(".sr-item")?.querySelector(".sr-item__title")?.textContent?.trim() ||
card.getAttribute("aria-label")?.replace(/^播放[::]/, "").trim() ||
"视频播放";
card.getAttribute("aria-label")?.replace(/^(播放|Play)\s*[::]\s*/i, "").trim() ||
t("video.play");
openModal(card.getAttribute("data-video-src") || "", title);
});
});

6
public/themes/dist_static/static/js/video.js

@ -21,7 +21,7 @@ function initVideoModal() {
let lastFocus = null;
const openModal = (src, title) => {
lastFocus = document.activeElement;
titleEl.textContent = title || "视频播放";
titleEl.textContent = title || t("video.play");
if (video.getAttribute("src") !== src) video.src = src;
modal.hidden = false;
document.body.style.overflow = "hidden";
@ -40,7 +40,7 @@ function initVideoModal() {
};
document.querySelectorAll(".v-card").forEach((card) => {
card.addEventListener("click", () => {
openModal(card.getAttribute("data-video-src") || defaultSrc, card.querySelector(".v-card__title")?.textContent?.trim() || "视频播放");
openModal(card.getAttribute("data-video-src") || defaultSrc, card.querySelector(".v-card__title")?.textContent?.trim() || t("video.play"));
});
});
modal.querySelectorAll("[data-v-modal-close]").forEach((el) => {
@ -72,7 +72,7 @@ function initFilterDropdown() {
const $dropdown = $item.closest("[data-filter-dropdown]");
const $btn = $dropdown.prev("[data-filter-trigger]");
if ($item.is("[data-filter-clear]")) {
$btn.find("span").text("按产品筛选");
$btn.find("span").text(t("filter.by_product"));
$btn.removeClass("is-selected");
$dropdown.find(".is-active").removeClass("is-active");
$item.addClass("is-active");

Loading…
Cancel
Save