Skip to content

Commit

Permalink
feat: update translation, close 翻译新闻页面的站点状态 #1252
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Mar 17, 2024
1 parent 37bf632 commit 6aae82d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
26 changes: 19 additions & 7 deletions src/plugin/syringe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,29 @@ export class Syringe {
repText = repText.replace(k, v as (substring: string, ...args: any[]) => string);
}

if (this.config.translateTimestamp !== false) {
repText = repText.replace(/\d\d\d\d-\d\d-\d\d \d\d:\d\d/g, (t) => {
if (
this.config.translateTimestamp !== false &&
// 快速判断是否有可能包含时间戳
repText.includes(':')
) {
repText = repText.replace(/(\d\d\d\d-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9])( UTC)?/g, ($, t) => {
const date = Date.parse(t + 'Z');
if (!date) return t;
if (!date) return $;
return `${this.time.diff(date, undefined, DateTime.hour)}`;
});
repText = repText.replace(
/\d\d (January|February|March|April|May|June|July|August|September|October|November|December) \d\d\d\d, \d\d:\d\d/gi,
(t) => {
const date = Date.parse(t + ' UTC');
if (!date) return t;
/([0-3][0-9]|[1-9]) (January|February|March|April|May|June|July|August|September|October|November|December) (\d\d\d\d), ([0-2][0-9]:[0-5][0-9])( UTC)?/gi,
($, d, m, y, t) => {
const date = Date.parse(`${d} ${m} ${y}, ${t} UTC`);
if (!date) return $;
return `${this.time.diff(date, undefined, DateTime.hour)}`;
},
);
repText = repText.replace(
/(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), ([0-3][0-9]|[1-9])(st|nd|rd|th) of (January|February|March|April|May|June|July|August|September|October|November|December) (\d\d\d\d), ([0-2][0-9]:[0-5][0-9])( UTC)?/gi,
($, _w, d, _do, m, y, t) => {
const date = Date.parse(`${d} ${m} ${y}, ${t} UTC`);
if (!date) return $;
return `${this.time.diff(date, undefined, DateTime.hour)}`;
},
);
Expand Down
4 changes: 2 additions & 2 deletions src/services/ui-translation/data/bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ merge(
'New donations will typically show up here in less than two minutes. It will show as ':
'新的捐赠通常会在两分钟内显示在这里,但在被纳入一个区块并达到两个确认之前会处于 ',
' until it is included in a block and reaches two confirmations. This usually takes less than an hour, but can take longer in some cases. When it has been marked as ':
' 状态。这通常不需要一个小时,但在某些情况下可能会花费更长时间。只有当状态变更为 ',
' 状态。此状态一般不会超过一个小时,但在某些情况下可能会花费更长时间。只有当状态变更为 ',
', you still have to apply it below to make it take effect.': ' 时才能通过下方按钮完成捐赠。',
'No transactions in the past year.': '在过去一年内没有交易',
Pending: '待定',
Expand Down Expand Up @@ -124,7 +124,7 @@ merge(
'当前比特币 (BTC) 的交易手续费非常高,约 $1 sats/vB。我们强烈推荐使用比特币现金 (BCH)。',
],
[
/^Bitcoin \(BTC\) transaction fees are persistently high, and currently estimated to at least ([\d.]+) sats\/vB. We recommend using Bitcoin Cash \(BCH\) if possible.$/,
/^Bitcoin \(BTC\) transaction fees are persistently high, currently estimated to at least ([\d.]+) sats\/vB. We recommend using Bitcoin Cash \(BCH\) if possible.$/,
'当前比特币 (BTC) 的交易手续费居高不下,至少为 $1 sats/vB。如果可以的话,我们建议使用比特币现金 (BCH)。',
],
],
Expand Down
41 changes: 32 additions & 9 deletions src/services/ui-translation/data/news.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import { merge } from '../helper';

merge(/^\/news\.php/, undefined, {
'Latest Site Status Updates': '最新网站状态',
'You can follow ': '您可以',
'follow us on Twitter': '在推特上关注我们',
' to receive these site status updates if the site is ever unavailable.': '以便在网站不可用时获取网站状态信息。 ',
'Site Update Log': '网站更新日志',
'Previous Years: \xA0 ': '往年: ',
'Show Older News': '显示更早的新闻',
});
merge(
/^\/news\.php/,
undefined,
{
'Site Status': '网站状态',

'Lately we have been seeing a surge of old accounts with weak/compromised passwords being taken over by spammers, causing them to get banned.':
'最近我们看到了大量旧账户被垃圾邮件发送者接管,这些账户的密码较弱或已被泄露,导致它们被封禁。',
'If you still use a weak password or a password you ever used anywhere else, you need to change it as soon as possible.':
'如果你仍在使用较弱的密码或曾在其他地方使用过的密码,你需要尽快更改它。',
'We will ': '如果你忽略了这个警告并且发生了这种情况,我们将',
not: '不',
' manually restore access to your account if you ignore this warning and it happens to you.':
'会手动恢复你的账户访问权限。',

'Scheduled Downtime & Maintenance': '计划停机和维护',
'No maintenance is currently ongoing or scheduled.': '目前没有正在进行或计划中的维护。',

'Automated Monitoring Status': '自动监控状态',
'No server issues have been detected by the monitoring system.': '监控系统未检测到服务器问题。',

'Site Changelog': '网站更新日志',
'Changelogs: \xA0 ': '更新日志:',

'Show Older News': '显示更早的新闻',
},
[
[/^Last Monitoring Update: (\d\d\d\d-\d\d-\d\d \d\d:\d\d) UTC$/, '最后监控更新:$1 UTC'],
[/^Show (\d+) comment(s)?$/, '显示 $1 条评论'],
[/^Posted (.+?) UTC$/, '发布于 $1 UTC'],
],
);

0 comments on commit 6aae82d

Please sign in to comment.