Multilanguage Wiki - Found a solution, but need help for improving it

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 it i18n) 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 and Cosa for italian), and titles which are the same except for a suffix (tiddlers titled as words like “Internet”, so Internet:en and Internet: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

Example screenshot

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 called i18n:en, the bar will contain a link titled en. But what if I want to keep the short tag name, but make a full name appear in the bar, so English instead of en? 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! :slight_smile:

Welcome to the community @_oct, multiple language support is something TiddlyWiki is keen to do, and does so for its core settings, but leaves the balance of content to the wiki designers. Personally I am only fluent in one spoken language but have a little of another language, so I don’t have the language experience but I do have the tiddlywiki experience.

I am confident we can design some great multi-language solutions in TiddlyWiki as it is flexible enough and the community can help.

  • I see as a new user you have jumped in and started building a solution which is great to see, however I expect there is a danger that you/we go down one path over another.
  • Lets see if this thread is responded to by some of our truly multi-lingual designers and developers.

In the mean time some quick notes;

  • Publishing in one language and using Google Translate seems effective in some cases see About Google Translate as one.
    • Using Google translate as the first pass translation and capturing its result into tiddlywiki for further editing seems like a good workflow to me.
  • There are two issues about language content tiddler “titles” and their “content”.
    • We could use multiple language captions to use rather than the title that respond to the selected title. eg caption-lang however we need a definitive title when coding a solution.
    • We could create separate language multi-line text fields in tiddlers as well. text-lang eg text-en text-fr

My personal feeling is if Google Translate does not work for you, trying to come up with a general solution for tiddlywiki to support multiple-languages content may be an easier approach than responding to your specific use case.

  • If you want to proceed with your current approach perhaps set up a public site on tiddlyhost.com and set up a minimal case you can use to illustrate where you are and what needs fixing.
  • Consider asking more general questions and share some simple examples where you want support rather than asking questions against your current wiki design. It is easier for us to answer questions about tiddlywiki than it is to answer questions about your wiki.

Moin, my one short Comment:
don’t involve Google to deep for translation. One Day the will charge for it.
You all, have a good day and night too.

1 Like

@Paralullus welcome to talk.tiddlywiki

You make an important point about depending on free services, but I am not so sure if depending on google translate is a mistake. Since google is all about search and advertising, I think they want to maximise the content that draws our attention and would be unlikely to charge unless you have commercial volumes of translations - although I have no evidence either way.

Also my idea about using Google translate was use it to provide the translations which you then copy and include in the wiki so it can be taken off line, that is you NEED the translation when writing content.

Hi @TW_Tones, thank you for your tips.

The idea of using machine translation tools instead of rewriting everything by hand is a good idea to keep in mind, but in this case it goes beyond the scope of my questions, which are about tweaking TiddlyWiki to well support a multi-language wiki, not the workflow of creating or managing one.

If I can manage any additional minor improvement to my solution, I might create a demo TW (not part of my main one) to organize and show ideas about the matter. In the meantime, yes, let’s wait for if someone with actual development experience in TiddlyWiki can come here and help us out!

TW_Tones, thanks for welcoming me here.

In my case I like and use Youtube more then regular TV soup. For me it is more about other people, themes and homes. AND I pay month by month not to see commercial insertions.

Have a good day