diff --git a/static/payment/static/js/core.min.js b/static/payment/static/js/core.min.js index 420f363..dbc0555 100644 --- a/static/payment/static/js/core.min.js +++ b/static/payment/static/js/core.min.js @@ -52,6 +52,27 @@ }); } + function getPaymentConfig() { + const container = document.querySelector('.payment-container'); + if (!container) return {}; + + return { + token: container.getAttribute('data-token') || 'USDT', + network: container.getAttribute('data-network') || 'TRC20', + networkName: container.getAttribute('data-network-name') || 'TRON', + warningToken: container.getAttribute('data-warning-token') || 'TRX' + }; + } + + function replacePlaceholders(text) { + const config = getPaymentConfig(); + return text + .replace(/\{\{token\}\}/g, config.token) + .replace(/\{\{network\}\}/g, config.network) + .replace(/\{\{networkName\}\}/g, config.networkName) + .replace(/\{\{warningToken\}\}/g, config.warningToken); + } + function updateContent() { document.querySelectorAll('[data-i18n]').forEach(function (element) { const key = element.getAttribute('data-i18n'); @@ -60,14 +81,17 @@ if (matches) { const attr = matches[1]; const transKey = matches[2]; + let translation = i18next.t(transKey); + translation = replacePlaceholders(translation); if (attr === 'html') { - element.innerHTML = i18next.t(transKey); + element.innerHTML = translation; } else { - element.setAttribute(attr, i18next.t(transKey)); + element.setAttribute(attr, translation); } } } else { - const translation = i18next.t(key); + let translation = i18next.t(key); + translation = replacePlaceholders(translation); if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') { element.placeholder = translation; } else { diff --git a/static/payment/static/locales/README.md b/static/payment/static/locales/README.md deleted file mode 100644 index 89c3929..0000000 --- a/static/payment/static/locales/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# 国际化语言文件 - -## 文件说明 - -- `zh.json` - 中文翻译 -- `en.json` - 英文翻译 - -## 使用方式 - -页面会自动根据浏览器语言设置选择对应的语言包: -- 如果浏览器语言是中文(zh),则显示中文 -- 如果浏览器语言是英文(en),则显示英文 -- 其他语言默认显示英文 - -用户也可以通过右上角的语言切换器手动切换语言,选择会保存在 localStorage 中。 - -## 添加新语言 - -如果需要添加新语言,请: -1. 在此目录创建新的语言文件,如 `ja.json`(日语) -2. 复制 `en.json` 的结构,翻译所有内容 -3. 在模板文件的语言切换器中添加新选项 -4. 更新 JavaScript 代码中的语言检测逻辑 - -## 翻译内容 - -包含以下内容的翻译: -- 页面标题和说明 -- 订单信息标签 -- 倒计时文字 -- 收款地址标签 -- 转账说明 -- 弹窗提示消息(支付超时、网络确认、支付成功) -- 复制功能反馈 - diff --git a/static/payment/static/locales/en.json b/static/payment/static/locales/en.json index d1bbff9..c0e5f70 100644 --- a/static/payment/static/locales/en.json +++ b/static/payment/static/locales/en.json @@ -1,8 +1,8 @@ { "payment": { - "title": "USDT Payment", - "subtitle": "Please use TRON TRC20 network for transfer", - "networkBadge": "TRC20", + "title": "{{token}} Payment", + "subtitle": "Please use {{networkName}} {{network}} network for transfer", + "networkBadge": "{{network}}", "paymentAmount": "Payment Amount:", "merchantOrder": "Merchant Order:", "orderAmount": "Order Amount:", @@ -12,10 +12,10 @@ "countdownSubtitle": "Please complete the transfer within the specified time. Do not pay if timeout, reorder instead", "minutes": "min", "seconds": "sec", - "addressLabel": "Receiving Address (TRC20 Network)", + "addressLabel": "Receiving Address ({{network}} Network)", "copyAddress": "Copy Address", "instructionsTitle": "📋 Transfer Instructions", - "instruction1": "Must use TRC20 network for transfer, do not send TRX!", + "instruction1": "Must use {{network}} network for transfer, do not send {{warningToken}}!", "instruction2": "The system will automatically confirm the receipt after transfer", "instruction3": "Transfer amount must exactly match the displayed amount", "instruction4": "If you have any questions, please contact customer service", diff --git a/static/payment/static/locales/zh.json b/static/payment/static/locales/zh.json index f0eddb8..d24f28a 100644 --- a/static/payment/static/locales/zh.json +++ b/static/payment/static/locales/zh.json @@ -1,8 +1,8 @@ { "payment": { - "title": "USDT 支付", - "subtitle": "请使用 波场 (TRON) TRC20 网络进行转账", - "networkBadge": "TRC20", + "title": "{{token}} 支付", + "subtitle": "请使用 {{networkName}} {{network}} 网络进行转账", + "networkBadge": "{{network}}", "paymentAmount": "付款数额:", "merchantOrder": "商户订单:", "orderAmount": "订单金额:", @@ -12,10 +12,10 @@ "countdownSubtitle": "请在指定时间内完成转账,超时勿付请重新下单", "minutes": "分", "seconds": "秒", - "addressLabel": "收款地址 (TRC20 网络)", + "addressLabel": "收款地址 ({{network}} 网络)", "copyAddress": "复制地址", "instructionsTitle": "📋 转账说明", - "instruction1": "必须使用 TRC20 网络 进行转账,请勿转入 TRX!", + "instruction1": "必须使用 {{network}} 网络 进行转账,请勿转入 {{warningToken}}!", "instruction2": "转账完成后系统会自动确认到账", "instruction3": "转账金额必须与显示金额完全一致", "instruction4": "如果有其它疑问,请联系客服处理", diff --git a/static/payment/views/bsc.bnb.html b/static/payment/views/bsc.bnb.html index 9fbac7f..99c3c81 100644 --- a/static/payment/views/bsc.bnb.html +++ b/static/payment/views/bsc.bnb.html @@ -14,7 +14,7 @@
-+ + 请使用 以太坊 (Ethereum) ERC20 网络进行转账 + ERC20 +
+ +- - 请使用 以太坊 (Ethereum) ERC20 网络进行转账 - ERC20 -
- -