From cacd236f71fc1491cbe1d03f9dcbfbf8b3e2cf20 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Wed, 13 Dec 2023 23:22:12 +0800 Subject: [PATCH] feat: support block mode so you can transclude whole tiddler --- core/wiki/macros/lingo.tid | 4 +-- editions/tw5.com/tiddlers/macros/t Macro.tid | 38 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/core/wiki/macros/lingo.tid b/core/wiki/macros/lingo.tid index 332b2e239..a5e746f4c 100644 --- a/core/wiki/macros/lingo.tid +++ b/core/wiki/macros/lingo.tid @@ -9,13 +9,13 @@ $:/language/ {{$(lingo-base)$$title$}} \end -\define t(key,lingo-base-fallback:"") +\define t(key,lingo-base-fallback:"",mode:block) <$set name="lingoBaseWithFallback" value="$lingo-base-fallback$" emptyValue=<>> <$set name="lang" filter="[[$:/language]get[text]get[name]else[en-GB]]" select="0"> <$set name="l10nTarget" filter="[suffix[/]then] ~[addsuffix[/]] +[addsuffixaddsuffix[/]addsuffix<__key__>]" select="0"> - <$transclude $tiddler=<> /> + <$transclude $tiddler=<> $mode="$mode$" /> diff --git a/editions/tw5.com/tiddlers/macros/t Macro.tid b/editions/tw5.com/tiddlers/macros/t Macro.tid index 11804a309..6789ce045 100644 --- a/editions/tw5.com/tiddlers/macros/t Macro.tid +++ b/editions/tw5.com/tiddlers/macros/t Macro.tid @@ -14,23 +14,31 @@ The difference to [[lingo Macro]] is that translatable text can be directly plac : The last part of title of the tiddler that contains the text. The `<>` prefix and current language name prefix is added automatically ;lingo-base-fallback : Optional lingo-base when it is not possible to define `lingo-base` variable (for example, when using this macro in the caption field), you can set the lingo base by passing this parameter +;mode +: Optional parameter like the "mode" parameter in [[TranscludeWidget]], default to "block". <<.macro-examples "t">> !! Example file structure in plugin +!!! Suggested file structure + When developing a plugin, you may want to organize your i18n (internationalization) files like this on the file system as [[MultiTiddlerFiles]]: ```tree ├── i18n │ ├── en-GB -│ │ └── Translations.multids +│ │ ├── Translations.multids +│ │ └── SomeLongText.tid │ └── zh-Hans -│ └── Translations.multids +│ ├── Translations.multids +│ └── SomeLongText.tid ├── other files └── plugin.info ``` +!!! Define Multiple Translations in One Tiddler + And the content of `i18n/en-GB/Translations.multids` may looks like this: ```multids @@ -50,4 +58,28 @@ caption: <> \whitespace trim <> -``` \ No newline at end of file +``` + +!!! Define Long Text in regular Tiddler + +You can also use a regular tiddler for long text, like `SomeLongText.tid` in the example above, to store a multi-paragraph long text: + +```tid +title: $:/plugins/yourName/pluginName/languages/en-GB/SomeLongText + +!!! SubTitle + +This is a long text. +``` + +Later you can use it like: + +```tid +title: someTiddler + +\define lingo-base() $:/plugins/yourName/pluginName/languages/ + +!! <> + +<> +```