mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-08 08:20:27 +00:00
23 lines
862 B
Plaintext
23 lines
862 B
Plaintext
title: $:/core/macros/lingo
|
|
tags: $:/tags/Macro
|
|
|
|
\define lingo-base()
|
|
$:/language/
|
|
\end
|
|
|
|
\define lingo(title)
|
|
{{$(lingo-base)$$title$}}
|
|
\end
|
|
|
|
\define t(key,lingo-base-fallback:"")
|
|
<!-- 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>> />
|
|
</$set>
|
|
</$set>
|
|
</$set>
|
|
\end
|