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 @@ -
+
- - - +
+
+ +
+ +
ETH
+

ETH 支付

+

+ + 请使用 以太坊 (Ethereum) ERC20 网络进行转账 + ERC20 +

+ +
+
+ 付款数额: + {{.amount}} ETH
- -
ETH
-

ETH 支付

-

- - 请使用 以太坊 (Ethereum) ERC20 网络进行转账 - ERC20 -

- -
-
- 付款数额: - {{.amount}} ETH -
-
- 商户订单: - {{.order_id}} -
-
- 订单金额: - - 约 {{.money}} {{.fiat}} +
+ 商户订单: + {{.order_id}} +
+
+ 订单金额: + + 约 {{.money}} {{.fiat}} -
-
-
-
-
⏰ 支付倒计时
-
请在指定时间内完成转账,超时勿付请重新下单
-
-
-
- 15 - 分 -
- : -
- 00 - 秒 -
+
+
+
+
+
⏰ 支付倒计时
+
+ 请在指定时间内完成转账,超时勿付请重新下单
-
-
-
-
-
收款地址 (ERC20 网络)
-
{{.address}}
- -
-
-
-

📋 转账说明

-
    -
  1. 必须使用 ERC20 网络 进行转账,请勿转入 USDT/USDC!
  2. -
  3. 转账完成后系统会自动确认到账
  4. -
  5. 转账金额必须与显示金额完全一致
  6. -
  7. 如果有其它疑问,请联系客服处理
  8. -
-
- - - + }); + - \ No newline at end of file diff --git a/static/payment/views/tron.trx.html b/static/payment/views/tron.trx.html index fe9ae0d..5a2745b 100644 --- a/static/payment/views/tron.trx.html +++ b/static/payment/views/tron.trx.html @@ -14,7 +14,7 @@ -
+
+ + + +
+ +
USDC
+

USDC 支付

+

+ + 请使用 以太坊 (Ethereum) ERC20 网络进行转账 + ERC20 +

+ +
+
+ 付款数额: + {{.amount}} USDC +
+
+ 商户订单: + {{.order_id}} +
+
+ 订单金额: + + 约 {{.money}} {{.fiat}} + +
+
+
+
+
+
⏰ 支付倒计时
+
请在指定时间内完成转账,超时勿付请重新下单
+
+
+
+ 15 + 分 +
+ : +
+ 00 + 秒 +
+
+
+
+
+
+
+
收款地址 (ERC20 网络)
+
{{.address}}
+ +
+
+
+

📋 转账说明

+
    +
  1. 必须使用 ERC20 网络 进行转账,请勿转入 ETH!
  2. +
  3. 转账完成后系统会自动确认到账
  4. +
  5. 转账金额必须与显示金额完全一致
  6. +
  7. 如果有其它疑问,请联系客服处理
  8. +
+
+ +
+ + + + + + diff --git a/static/payment/views/usdc.polygon.html b/static/payment/views/usdc.polygon.html index 51fe213..1f43b4f 100644 --- a/static/payment/views/usdc.polygon.html +++ b/static/payment/views/usdc.polygon.html @@ -1,178 +1,111 @@ - - - - - }); - }); - return_url: "{{.return_url}}" - trade_id: "{{.trade_id}}", - amount: "{{.amount}}", - address: "{{.address}}", - expire: "{{.expire}}", - Payment.init({ - document.addEventListener('DOMContentLoaded', function () { - - } - }); - updateContent(); - localStorage.setItem('payment_language', lang); - currentLang = lang; - } - return; - console.error('Language change failed:', err); - if (err) { - i18next.changeLanguage(lang, function(err, t) { - function changeLanguage(lang) { - - } - }); - } - } - element.innerHTML = translation; - } else { - element.placeholder = translation; - if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') { - const translation = i18next.t(key); - } else { - } - } - element.setAttribute(attr, i18next.t(transKey)); - } else { - element.innerHTML = i18next.t(transKey); - if (attr === 'html') { - const transKey = matches[2]; - const attr = matches[1]; - if (matches) { - const matches = key.match(/\[(.+?)\](.+)/); - if (key.startsWith('[')) { - const key = element.getAttribute('data-i18n'); - document.querySelectorAll('[data-i18n]').forEach(function(element) { - function updateContent() { - - }); - }); - console.error('Failed to load language files:', error); - }).catch(function(error) { - document.getElementById('languageSwitcher').value = currentLang; - updateContent(); - i18next.addResourceBundle('en', 'translation', enData); - i18next.addResourceBundle('zh', 'translation', zhData); - ]).then(function([zhData, enData]) { - fetch('/payment/locales/en.json').then(r => r.json()) - fetch('/payment/locales/zh.json').then(r => r.json()), - Promise.all([ - - } - return; - console.error('i18next initialization failed:', err); - if (err) { - }, function(err, t) { - } - en: { translation: {} } - zh: { translation: {} }, - resources: { - debug: false, - lng: currentLang, - i18next.init({ - - } - currentLang = 'en'; - if (currentLang !== 'zh' && currentLang !== 'en') { - let currentLang = localStorage.getItem('payment_language') || navigator.language.split('-')[0] || 'en'; - - - - - - - USDC・Polygon 一款更好用的个人USDC收款网关 BEpusdt - - - - + + + + USDC・Polygon 一款更好用的个人USDC收款网关 BEpusdt + + + + + + + + + +
+
+ +
+ +
USDC
+

USDC 支付

+

+ + 请使用 Polygon 网络进行转账 + Polygon +

+ +
+
+ 付款数额: + {{.amount}} USDC +
+
+ 商户订单: + {{.order_id}} +
+
+ 订单金额: + + 约 {{.money}} {{.fiat}} + +
+
+
+
+
+
⏰ 支付倒计时
+
请在指定时间内完成转账,超时勿付请重新下单
+
+
+
+ 15 + 分 +
+ : +
+ 00 + 秒 +
+
+
+
+
+
+
+
收款地址 (Polygon 网络)
+
{{.address}}
+ +
+
+
+

📋 转账说明

+
    +
  1. 必须使用 Polygon 网络 进行转账,请勿转入 POL/MATIC!
  2. +
  3. 转账完成后系统会自动确认到账
  4. +
  5. 转账金额必须与显示金额完全一致
  6. +
  7. 如果有其它疑问,请联系客服处理
  8. +
+
+ +
+ + + + + + diff --git a/static/payment/views/usdc.solana.html b/static/payment/views/usdc.solana.html index 0d9b620..4584023 100644 --- a/static/payment/views/usdc.solana.html +++ b/static/payment/views/usdc.solana.html @@ -14,7 +14,7 @@ -
+
diff --git a/static/payment/views/usdc.xlayer.html b/static/payment/views/usdc.xlayer.html index c7c7008..861c809 100644 --- a/static/payment/views/usdc.xlayer.html +++ b/static/payment/views/usdc.xlayer.html @@ -14,7 +14,7 @@ -
+
diff --git a/static/payment/views/usdt.arbitrum.html b/static/payment/views/usdt.arbitrum.html index 5923fa7..be627a1 100644 --- a/static/payment/views/usdt.arbitrum.html +++ b/static/payment/views/usdt.arbitrum.html @@ -14,7 +14,7 @@ -
+
diff --git a/static/payment/views/usdt.erc20.html b/static/payment/views/usdt.erc20.html index 5a5e5c8..df0b27c 100644 --- a/static/payment/views/usdt.erc20.html +++ b/static/payment/views/usdt.erc20.html @@ -14,7 +14,7 @@ -
+
diff --git a/static/payment/views/usdt.polygon.html b/static/payment/views/usdt.polygon.html index 77e5957..1757176 100644 --- a/static/payment/views/usdt.polygon.html +++ b/static/payment/views/usdt.polygon.html @@ -14,7 +14,7 @@ -
+
diff --git a/static/payment/views/usdt.trc20.html b/static/payment/views/usdt.trc20.html index 7d621bb..02c50b5 100644 --- a/static/payment/views/usdt.trc20.html +++ b/static/payment/views/usdt.trc20.html @@ -12,7 +12,7 @@ -
+