mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-14 23:03:16 +00:00
feat: support block mode so you can transclude whole tiddler
This commit is contained in:
parent
a6b61323ec
commit
cacd236f71
@ -9,13 +9,13 @@ $:/language/
|
||||
{{$(lingo-base)$$title$}}
|
||||
\end
|
||||
|
||||
\define t(key,lingo-base-fallback:"")
|
||||
\define t(key,lingo-base-fallback:"",mode:block)
|
||||
<!-- Allow assign lingo-base in caption field by accepting the lingo-base-fallback param. -->
|
||||
<$set name="lingoBaseWithFallback" value="$lingo-base-fallback$" emptyValue=<<lingo-base>>>
|
||||
<$set name="lang" filter="[[$:/language]get[text]get[name]else[en-GB]]" select="0">
|
||||
<!-- Allow lingo-base to have or not have / ending slash, for better dev experience. Then add, e.g. `en-GB/Key` after it. -->
|
||||
<$set name="l10nTarget" filter="[<lingoBaseWithFallback>suffix[/]then<lingoBaseWithFallback>] ~[<lingoBaseWithFallback>addsuffix[/]] +[addsuffix<lang>addsuffix[/]addsuffix<__key__>]" select="0">
|
||||
<$transclude $tiddler=<<l10nTarget>> />
|
||||
<$transclude $tiddler=<<l10nTarget>> $mode="$mode$" />
|
||||
</$set>
|
||||
</$set>
|
||||
</$set>
|
||||
|
@ -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 `<<lingo-base>>` 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: <<t "OpenStaticCard" "$:/plugins/yourName/pluginName/languages/">>
|
||||
\whitespace trim
|
||||
|
||||
<<t "OpenInteractiveCard">>
|
||||
```
|
||||
```
|
||||
|
||||
!!! 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/
|
||||
|
||||
!! <<t "OpenInteractiveCard">>
|
||||
|
||||
<<t "SomeLongText">>
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user