From 7aec0e122bd1bdacd119377ad752d4ad79c459d3 Mon Sep 17 00:00:00 2001 From: Leilei332 Date: Fri, 10 Jan 2025 21:51:32 +0800 Subject: [PATCH] Make draft title translatable --- core/language/en-GB/DraftAuthor.tid | 3 +++ core/language/en-GB/DraftNumber.tid | 3 +++ core/language/en-GB/Misc.multids | 2 ++ core/modules/wiki.js | 7 +++++-- languages/zh-Hans/Misc.multids | 3 +++ 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 core/language/en-GB/DraftAuthor.tid create mode 100644 core/language/en-GB/DraftNumber.tid diff --git a/core/language/en-GB/DraftAuthor.tid b/core/language/en-GB/DraftAuthor.tid new file mode 100644 index 000000000..14980ab64 --- /dev/null +++ b/core/language/en-GB/DraftAuthor.tid @@ -0,0 +1,3 @@ +title: $:/language/DraftAuthor + + by $1$ \ No newline at end of file diff --git a/core/language/en-GB/DraftNumber.tid b/core/language/en-GB/DraftNumber.tid new file mode 100644 index 000000000..5b5cff1c5 --- /dev/null +++ b/core/language/en-GB/DraftNumber.tid @@ -0,0 +1,3 @@ +title: $:/language/DraftNumber + +$1$ \ No newline at end of file diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index d8c091375..0d24d249b 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -15,6 +15,8 @@ ConfirmAction: Do you wish to proceed? Count: count DefaultNewTiddlerTitle: New Tiddler Diffs/CountMessage: <> differences + +DraftTitle: Draft $1$of '$2$'$3$ DropMessage: Drop now (or use the 'Escape' key to cancel) Encryption/Cancel: Cancel Encryption/ConfirmClearPassword: Do you wish to clear the password? This will remove the encryption applied when saving this wiki diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 29a839c7a..b456809a5 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -1701,9 +1701,12 @@ exports.generateDraftTitle = function(title) { var c = 0, draftTitle, username = this.getTiddlerText("$:/status/UserName"), - attribution = username ? " by " + username : ""; + draftBaseTitle = $tw.language.getRawString("DraftTitle"), + draftAuthor = $tw.language.getRawString("DraftAuthor"), + draftNumber = $tw.language.getRawString("DraftNumber"), + attribution = username ? draftAuthor.replace("$1$",username) : ""; do { - draftTitle = "Draft " + (c ? (c + 1) + " " : "") + "of '" + title + "'" + attribution; + draftTitle = draftBaseTitle.replace("$1$", (c ? draftNumber.replace(draftNumber, "$1$") : "")).replace("$2$", title).replace("$3$",attribution); c++; } while(this.tiddlerExists(draftTitle)); return draftTitle; diff --git a/languages/zh-Hans/Misc.multids b/languages/zh-Hans/Misc.multids index 030e30c6a..f03cfbdcb 100644 --- a/languages/zh-Hans/Misc.multids +++ b/languages/zh-Hans/Misc.multids @@ -15,6 +15,9 @@ ConfirmAction: 是否要继续? Count: 计数 DefaultNewTiddlerTitle: 新条目 Diffs/CountMessage: <> 个差异 +DraftAuthor: $1$撰写的 +DraftNumber: $1$ +DraftTitle: $3$“$2$”的草稿$1$ DropMessage: 现在放下(或按 ESC 键取消) Encryption/Cancel: 取消 Encryption/ConfirmClearPassword: 您要清除密码吗?当保存此维基时,这将删除已套用的加密