forked from TiddlyWiki/TiddlyWiki5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
editions/tw5.com/tiddlers/macros/examples/t Macro (Examples).tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
created: 20231028120432257 | ||
modified: 20231028122408606 | ||
tags: [[t Macro]] [[Macro Examples]] | ||
title: t Macro (Examples) | ||
|
||
\define lingo-base() t Macro (Examples) | ||
|
||
Given the `\define lingo-base() t Macro (Examples)`, this example shows the localizaion key `ExampleKey` being translate to the text in [[t Macro (Examples)/en-GB/ExampleKey]]: | ||
|
||
<$macrocall $name=".example" n="1" eg="""<<t ExampleKey>>"""/> | ||
|
||
This example shows the `lingo-base` can be set inline as second parameter: | ||
|
||
<$macrocall $name=".example" n="2" eg="""<<t ExampleKey "t Macro (Examples)">>"""/> |
5 changes: 5 additions & 0 deletions
5
editions/tw5.com/tiddlers/macros/examples/t Macro (Examples)_en-GB_ExampleKey.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
created: 20231028120526948 | ||
modified: 20231028123420761 | ||
title: t Macro (Examples)/en-GB/ExampleKey | ||
|
||
This is the translated text of key "~ExampleKey" under lingo-base `t Macro (Examples)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
caption: t (translation) | ||
created: 20231028115714556 | ||
modified: 20231028123219684 | ||
tags: Macros [[Core Macros]] | ||
title: t Macro | ||
|
||
The <<.def t>> [[macro|Macros]] relates to the translation of ~TiddlyWiki's user interface into other languages, just like [[lingo Macro]]. It returns a piece of text in the user's currently selected language. And `t` is the abbreviation of "translation". | ||
|
||
The difference to [[lingo Macro]] is that translatable text can be directly placed in user's wiki, instead of in a language plugin. | ||
|
||
!! Parameters | ||
|
||
;key | ||
: 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 | ||
|
||
<<.macro-examples "t">> | ||
|
||
!! Example file structure in plugin | ||
|
||
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 | ||
│ └── zh-Hans | ||
│ └── Translations.multids | ||
├── other files | ||
└── plugin.info | ||
``` | ||
|
||
And the content of `i18n/en-GB/Translations.multids` may looks like this: | ||
|
||
```multids | ||
title: $:/plugins/yourName/pluginName/languages/en-GB/ | ||
|
||
OpenInteractiveCard: Open Interactive Card | ||
OpenStaticCard: Open Static Card | ||
``` | ||
|
||
Later you can use it like: | ||
|
||
```tid | ||
title: someTiddler | ||
caption: <<t "OpenStaticCard" "$:/plugins/yourName/pluginName/languages/">> | ||
|
||
\define lingo-base() $:/plugins/yourName/pluginName/languages/ | ||
\whitespace trim | ||
|
||
<<t "OpenInteractiveCard">> | ||
``` |