First of all, hi everyone, this is my first post here after just about a week of ever using TiddlyWiki.
I’m really liking TW so far, but was dissatisfied to see that the software has no integrated way of easily building a multilanguage wiki, something that can be done reasonably well on MediaWiki with the translations plugin.
I did look around here and on the old usenet forum, but haven’t found a complete third-party solution to easily get what I want, so yesterday evening I started trying to build my own.
My method is based on the following points:
- For each topic that has to be written in multiple languages, each translation resides in its own tiddler (so no double-language split view editor like I’ve seen people picture, each translation is handled separately)
- Each tiddler is tagged with a special tag to indicate its language (I chose
i18n:LANG
), and has a special field (I simply called iti18n
) set to a unique id to be shared among all the tiddlers that should appear as translation of each other
The use of a specific tag to indicate a language makes it easy to filter all tiddlers of a specific language for other purposes, while using a field to set a unique shared id is because:
- It stays out of the way and doesn’t uselessly pollute the tags list.
- It’s in my opinion a more elegant solution than what MediaWiki does for identifying which pages are translations of a certain topic, because it treats well both titles which differ across languages (tiddlers titled just as common words, like
Thing
for english andCosa
for italian), and titles which are the same except for a suffix (tiddlers titled as words like “Internet”, soInternet:en
andInternet:it
). - Renaming a tiddler won’t break its connected translations.
To actually use the thing, I had to create a macro that, when called (as <<i18n>>
) makes a language bar appear. Similar to MediaWiki, links in the bar are simply named as a certain language, and link to the corresponding translation of the current tiddler.
Code, I put it in a tiddler with the tag "$:/tags/Macro"
\define i18n-target()
<$list filter="[[$(currentTiddler)$]tags[]prefix[i18n:]split[:]last[]]">
<span style="Padding:8px;">
<<currentTiddler>>
</span>
</$list>
\end
\define i18n()
<style>
.LanguageBox {
border: solid black 1px;
padding: 4px;
font-size: larger;
text-align: center;
}
</style>
<div class="LanguageBox">
<$vars id={{!!i18n}}>
<$list filter="[!is[system]contains:i18n<id>]">
<$link>
<$macrocall $name="i18n-target"/>
</$link>
</$list>
</$vars>
</div>
\end
I already started using this exact code on my wiki (except for some custom CSS, that I’m not including here, that gives a rainbow border to the language bar), but I think this needs some improvements. I’m asking here for help because I’m having trouble finding a way to implement the following:
- How to show a custom language name in the bar? With my current code, the bar shows names for the special language tags, minus the
i18n:
suffix, so if my tag is calledi18n:en
, the bar will contain a link titleden
. But what if I want to keep the short tag name, but make a full name appear in the bar, soEnglish
instead ofen
? Either the macro should look for each full name of a language in a lookup table, or the tag itself should hold the full display name for the macro to extract… but how? - How to show a language flag next to the name? I’m having trouble understanding how to make the embedding of an internal image (from
$:/languages/LANG/icon
, not an URL) work inside a macro context like what I have in my code. And, unless the tag for each language is called exactly like the file or folder that the icon image resides in, here comes again the first subproblem of letting the macro “know” how to find the image. - How to avoid including the currently viewed language in the language bar, or make it just a text (not a clickable link) like MediaWiki does? Listing even the currently selected language in the bar can be confusing.
- How to make the
<<i18n>>
macro be called for any tiddler, without the need to include it in the tiddler text? I guess that, to achive this, the file holding the default tiddler template should be modified, but I can’t find exactly which file. Or maybe the correct way is another one?
Finally, for tiddlers which are titled the same across languages except for a suffix (like in my “Internet” example): how to automatically link to the correct variation of them in a text?
Let’s say that I’m writing a tiddler tagged with i18n:en
in which I want to link to Internet:en
in the text. How can I obtain a link that is simply titled Internet
, but correctly links to Internet:en
, writing just [[Internet]]
and not [[Internet|Internet:en]]
? While obviously keeping in mind what I described at the beginning of the post, so that not all of the tiddlers are tidled as WORD:LANG
, but some could have totally different names in different languages, and are connected together via the unique shared id (but those can be simply naturally written as they are in the text, like, following my initial example, [[Thing]]
).
Well, that was a lot. If, despite the verbosity, something isn’t really clear, feel free to ask for clarifications. Thanks to anyone willing to help, then!