The i18n macro, for those who wants a multilingual wiki

267 views
Skip to first unread message

Sylvain Comte

unread,
May 7, 2019, 8:28:41 AM5/7/19
to tiddl...@googlegroups.com
HelloThere,

sorry for the flood, but I have been working on various things and did not publish here during the process. But I think it's better to have one thread for each item...

First, let me introduce the i18n macro that will enable multilingual versions of your tiddlers (You will have to install corresponding languages plugin to make it work properly)
  • create the tiddler
  • use <<i18n>>
  • edit original and translated versions of your text
That's it, switching wiki language will also switch for your tiddlers...
cheers and stay tuned,

Mark S.

unread,
May 7, 2019, 1:15:03 PM5/7/19
to TiddlyWiki
Added to the TIddlyWiki Toolmap under Writing and editing - editing tools

Suggested wording of:

The macro is already included in all those plugins, so if you use one of them, you don't have to get it apart :

as

The macro is already included in the following plugins, so if you already use one of them, you don't have to get it separately:


SylvainComte

unread,
May 7, 2019, 2:21:26 PM5/7/19
to TiddlyWiki
Sounds good. Thank you for this.

Sylvain

oleghbond

unread,
Aug 4, 2019, 2:03:59 PM8/4/19
to TiddlyWiki
Thanks Sylvian for the i18n macro. 

I've got an idea to equip some of my open TW resources with multilingual capabilities. The demonstration of your site looks simple and convincing. 

However, in practice I stumbled immediately. I dragged-and-dropped the i18n macro into my test monolingual (EN) TW. I allowed the language switcher at the sidebar. Then I put in a tiddler text a macro expression sort of: '<<i18n "Щодо стандарту української російської мови" "$:/boa/texts" false "uk-UA">>' (from https://protw.github.io/ukr/). And then ... nothing happens. I'm sure I missed something important. However, the tips on the issue in internet are scarce and sparse. 

Could you help me as for a dummy to get your macro working? 

Grateful in advance. Olegh

вівторок, 7 травня 2019 р. 15:28:41 UTC+3 користувач SylvainComte написав:

SylvainComte

unread,
Aug 5, 2019, 6:10:44 AM8/5/19
to TiddlyWiki
Hi Olegh,

You seem do anything like it should be... You should have a message from the wiki telling you a tiddler is missing, or a crash message from the wiki.

 It's pretty hard to tell you what happens. Here are some hints / questions / reflexions, but I do not have any certainity.

- "Nothing happens" might be a sign that the macro was not loaded. As it is a js macro, you will have to save and reload the wiki before it works. Pretty sure you did, but "just in case"...
- Do you know which version of tiddlywiki you are using? I'm unsure if my macro is using some recent core features.
- I did notice there is no official "uk-UA" language plugin in the TW library. It will not prevent you from creating your wiki, but you will have to create a (at least a fake one) plugin to allow language switching.

As an example, I took your protw.github.io sample and made some edit to demonstrate the plugin. If you can't get what happened and if you don't mind, feel free to join your own "not working" wiki. I could make some tests to investigate further.

warm regards,

Sylvain
@sycom
ukr-tw.html

oleghbond

unread,
Aug 6, 2019, 7:52:53 AM8/6/19
to TiddlyWiki
While I'm getting through could you tell - what is about tiddlers' titles translation?

понеділок, 5 серпня 2019 р. 13:10:44 UTC+3 користувач SylvainComte написав:

oleghbond

unread,
Aug 6, 2019, 9:42:11 AM8/6/19
to TiddlyWiki
Thanks for your support. As though I've managed to sort out the issue.

That is the pseudo-plugin:

author: OleghBondarenko
core
-version: >=5.0.0
description
: Ukrainian (Ukrainian)
name
: uk-UA
plugin
-type: language
title
: $:/languages/uk-UA
type
: application/json

{"tiddlers": {}}

and this is the flag:

title: $:/languages/uk-UA/icon
type
: image/svg+xml

<svg xmlns="http://www.w3.org/2000/svg" height="480" width="640" viewBox="0 0 640 480">
 
<g fill-rule="evenodd" stroke-width="1pt">
   
<path fill="#ffd500" d="M0 0h640v480H0z"/>
   
<path fill="#005bbb" d="M0 0h640v240H0z"/>
 
</g>
</
svg>

I checked and it works as you described.

However, the two following  issues left:
  1. How to make the Ukrainian flag to be revealed at the language switcher widget panel? At the moment I can see the text Ukrainian (Ukrainian) only.
  2. How to manage with translation of tiddler titles?
Olegh


понеділок, 5 серпня 2019 р. 13:10:44 UTC+3 користувач SylvainComte написав:
Hi Olegh,

Sylvain Comte

unread,
Aug 6, 2019, 11:15:27 AM8/6/19
to tiddl...@googlegroups.com
I can help you for one :

Your fake language plugin is almost good. The flag icon has to be embedded in the language plugin ($:/languages/uk-UA)

replace
{"tiddlers": {}}
with
{"tiddlers": {
   "$:/languages/uk-UA/icon":{
        "text": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"480\" width=\"640\" viewBox=\"0 0 640 480\">\n  <g fill-rule=\"evenodd\" stroke-width=\"1pt\">\n    <path fill=\"#ffd500\" d=\"M0 0h640v480H0z\"/>\n    <path fill=\"#005bbb\" d=\"M0 0h640v240H0z\"/>\n  </g>\n</svg>",
        "title": "$:/languages/uk-UA/icon",
        "type": "image/svg+xml"
    }
}}


For the second (title translations), a workaround could be modifying tiddler template ($:/core/ui/ViewTemplate/title) to display a lg-LG_title field (if exists through a $view widget) instead of <$view field="title" />. You will also have to put a macro to call the good field based upon $:/Language tiddler... But, as I told you before, no solution is simple for this. I'll take a look, but not immediately...

cheers

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/ATHJzp0SitM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/e1dc7793-028d-48d6-b768-e81010e3c40e%40googlegroups.com.

oleghbond

unread,
Aug 6, 2019, 4:14:43 PM8/6/19
to TiddlyWiki
Regarding the flag in the lang switcher - I checked - it works. Thanks.

The second issue is of principal importance for wide practical use of i18n plugin. It would be great if you'll sort out this issue. I'd like to mention importance of title translation not only in the tiddler view but also in TOC and other views.

I look forward to hearing from you on the issue solution progress.

вівторок, 6 серпня 2019 р. 18:15:27 UTC+3 користувач SylvainComte написав:
I can help you for one :

Your fake language plugin is almost good. The flag icon has to be embedded in the language plugin ($:/languages/uk-UA)

replace
{"tiddlers": {}}
with
{"tiddlers": {
   "$:/languages/uk-UA/icon":{
        "text": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"480\" width=\"640\" viewBox=\"0 0 640 480\">\n  <g fill-rule=\"evenodd\" stroke-width=\"1pt\">\n    <path fill=\"#ffd500\" d=\"M0 0h640v480H0z\"/>\n    <path fill=\"#005bbb\" d=\"M0 0h640v240H0z\"/>\n  </g>\n</svg>",
        "title": "$:/languages/uk-UA/icon",
        "type": "image/svg+xml"
    }
}}


For the second (title translations), a workaround could be modifying tiddler template ($:/core/ui/ViewTemplate/title) to display a lg-LG_title field (if exists through a $view widget) instead of <$view field="title" />. You will also have to put a macro to call the good field based upon $:/Language tiddler... But, as I told you before, no solution is simple for this. I'll take a look, but not immediately...

cheers

To unsubscribe from this group and all its topics, send an email to tiddl...@googlegroups.com.

Sylvain Comte

unread,
Aug 7, 2019, 3:54:12 AM8/7/19
to tiddl...@googlegroups.com
Hello Olegh,

I have not much time to explain here, but I made a demonstrator with a special note for you. With this recipe you should be able to do what you want. It's far from perfect and you will have a lot of job to translate all your wiki, but it will help for sure.

so far,

Sylvain
@sycom


To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f1f8f868-5881-45ac-91be-85d31a180d68%40googlegroups.com.
ukr-tw.html
Reply all
Reply to author
Forward
0 new messages