mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-03-07 06:20:46 -08:00
Make draft title translatable (#8891)
* Make draft title translatable * Update change note * Improve number handling Now generates "Draft of '...' 2" instead of "Draft 2 of '...'" * Improve whitespace handling We no longer needs to add whitespace in languages. We now handle it in javascript. * Update language naming * Update zh-Hans translation * Update change note * Refactor logic to make it less complex Since we don't need to care about draft numbers, we can have two different templates for draft title with and without attribution. No need to trim the string now. Also, we can reuse the getSubstitutedText method * Update translators edition * fixup! Update translators edition * Switch to transclude and variable mechanism * Adapt translators to the new mechanism * Update change note * Further simplify the logic $tw.language.getString can already wikify translatable strings. No need for this.renderText
This commit is contained in:
parent
9d5be2e9f8
commit
9c09841eda
11 changed files with 68 additions and 5 deletions
4
core/language/en-GB/Draft.multids
Normal file
4
core/language/en-GB/Draft.multids
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
title: $:/language/Draft/
|
||||
|
||||
Attribution: Draft of '<<draft-title>>' by {{$:/status/UserName}}
|
||||
Title: Draft of '<<draft-title>>'
|
||||
|
|
@ -1664,12 +1664,14 @@ exports.addToStory = function(title,fromTitle,storyTitle,options) {
|
|||
Generate a title for the draft of a given tiddler
|
||||
*/
|
||||
exports.generateDraftTitle = function(title) {
|
||||
var c = 0,
|
||||
draftTitle,
|
||||
username = this.getTiddlerText("$:/status/UserName"),
|
||||
attribution = username ? " by " + username : "";
|
||||
let c = 0,
|
||||
draftTitle;
|
||||
const username = this.getTiddlerText("$:/status/UserName");
|
||||
do {
|
||||
draftTitle = "Draft " + (c ? (c + 1) + " " : "") + "of '" + title + "'" + attribution;
|
||||
draftTitle = username ? $tw.language.getString("Draft/Attribution", {variables: {"draft-title": title}}) : $tw.language.getString("Draft/Title", {variables: {"draft-title": title}});
|
||||
if(c) {
|
||||
draftTitle = draftTitle.concat(" ", (c + 1).toString());
|
||||
}
|
||||
c++;
|
||||
} while(this.tiddlerExists(draftTitle));
|
||||
return draftTitle;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Prioritise the groups to translate first. A translation can be useful without be
|
|||
* Buttons
|
||||
* Control Panel
|
||||
* Date
|
||||
* Draft
|
||||
* Edit Template
|
||||
* Getting Started
|
||||
* Import
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
title: $:/status/UserName
|
||||
|
||||
Jermolene
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
"--render","$:/plugins/tiddlywiki/translators/templates/ControlPanel.multids","language/ControlPanel.multids","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/CoreReadMe.tid","language/CoreReadMe.tid","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/Dates.multids","language/Dates.multids","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/Draft.multids","language/Draft.multids","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/EditTemplate.multids","language/EditTemplate.multids","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/Exporters.multids","language/Exporters.multids","text/plain",
|
||||
"--render","$:/plugins/tiddlywiki/translators/templates/Fields.multids","language/Fields.multids","text/plain",
|
||||
|
|
|
|||
15
editions/tw5.com/tiddlers/releasenotes/5.4.0/draft-i18n.tid
Normal file
15
editions/tw5.com/tiddlers/releasenotes/5.4.0/draft-i18n.tid
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
title: $:/changenotes/5.4.0/#8891
|
||||
description: Draft title internationalization
|
||||
release: 5.4.0
|
||||
tags: $:/tags/ChangeNote
|
||||
change-type: enhancement
|
||||
change-category: internal
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8891
|
||||
github-contributors: Leilei332
|
||||
|
||||
The title of the draft tiddler is now translatable. These new language strings are provided:
|
||||
|
||||
* `$:/language/Draft/Title` The template of the title of a draft tiddler without attribution. The `draft-title` variable represents the title of the new tiddler.
|
||||
* `$:/language/Draft/Attribution` The template of the title of a draft tiddler without attribution.
|
||||
|
||||
The translators plugin is also updated.
|
||||
4
languages/zh-Hans/Draft.multids
Normal file
4
languages/zh-Hans/Draft.multids
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
title: $:/language/Draft/
|
||||
|
||||
Attribution: {{$:/status/UserName}}撰写的“<<draft-title>>”的草稿
|
||||
Title: “<<draft-title>>”的草稿
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
title: $:/plugins/tiddlywiki/translators/templates/Draft.multids
|
||||
|
||||
{{$:/language/Draft/||$:/plugins/tiddlywiki/translators/templates/multids}}
|
||||
|
|
@ -4,6 +4,7 @@ title: $:/plugins/tiddlywiki/translators/templates/Misc.multids
|
|||
-[all[tiddlers]prefix[$:/language/Buttons/]]
|
||||
-[all[tiddlers]prefix[$:/language/ControlPanel/]]
|
||||
-[all[tiddlers]prefix[$:/language/Date/]]
|
||||
-[all[tiddlers]prefix[$:/language/Draft/]]
|
||||
-[all[tiddlers]prefix[$:/language/Docs/]]
|
||||
-[all[tiddlers]prefix[$:/language/EditTemplate/]]
|
||||
-[all[tiddlers]prefix[$:/language/Exporters/]]
|
||||
|
|
|
|||
28
plugins/tiddlywiki/translators/ui/group/Draft.tid
Normal file
28
plugins/tiddlywiki/translators/ui/group/Draft.tid
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
title: $:/plugins/tiddlywiki/translators/ui/group/Draft
|
||||
caption: Draft
|
||||
tags: $:/tags/TranslationGroup
|
||||
|
||||
\procedure translatableTiddlerTitles()
|
||||
[all[tiddlers+shadows]prefix[$:/language/Draft/]]
|
||||
+[sort[title]]
|
||||
\end
|
||||
\procedure shortenTitle()
|
||||
[all[current]removeprefix[$:/language/Draft/]]
|
||||
\end
|
||||
|
||||
! Draft
|
||||
|
||||
Template for the title of draft tiddlers.
|
||||
|
||||
Substitution result:
|
||||
|
||||
<$let draft-title="Motovun Jack">
|
||||
<$wikify name="draft-with-attribution" text={{$:/language/Draft/Attribution}} output="text">
|
||||
<$wikify name="draft-without-attribution" text={{$:/language/Draft/Title}} output="text">
|
||||
<$codeblock code=<<draft-with-attribution>>/>
|
||||
<$codeblock code=<<draft-without-attribution>>/>
|
||||
</$wikify>
|
||||
</$wikify>
|
||||
</$let>
|
||||
|
||||
<<translatableStringEditor>>
|
||||
|
|
@ -6,6 +6,7 @@ tags: $:/tags/TranslationGroup
|
|||
[all[tiddlers+shadows]prefix[$:/language/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/Buttons/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/ControlPanel/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/Draft/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/Date/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/Docs/]]
|
||||
-[all[tiddlers+shadows]prefix[$:/language/EditTemplate/]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue