How to translate 3rd party plugin?

I searched for the issue and this forum, can’t find a solution for the official API / Widget for thrid party plugin i18n.

Can we use the same method as the core to do the translation? My plugins are English only or Chinese only currently, I hope I can make them internationalization.


Found a legacy thread here Plugins that expose strings should be translatable · Issue #786 · Jermolene/TiddlyWiki5 · GitHub

Seems I already come across one propersal Proposal : integrate a translation macro into the core · Issue #4179 · Jermolene/TiddlyWiki5 · GitHub but I totally forget.

1 Like

There is a Draft PR at Github, that implements a possible concept for translatable plugins.

It is a working solution. But there is no consens yet how the UI should be implemented.

IMO the main problem was, that I needed to change 50 files. I used the tiddlywiki menubar plugin to show the concept. I needed to change all the languag-files 2 times and I needed to add a test-library server to be able to test anything.

This server adds additional complexity to the PR. … With TW v5.2.24 this library-test server will be part of the default editions. … So the draft-PR can be simplified and 14 files can be removed.

I also found a bug in the plugin-library icon handling, which is there for ever, but only visible in the plugin import popup, if the plugin uses a custom icon. …

I needed to add code indentation to the main plugin-macro tiddler. The plugin handling UI is one of the most complex wikitext code we have in the whole system. … Making the wikitext code human readable is usually a separated PR which can take several weeks to be merged.

I still think the directory structure introduced in the PR is easy to implement and maintainable for both the core-devs and for plugin authors.

I would need to have a closer look again. AND I’d also have to have a closer look at the issues you mentioned in the OP.

2 Likes

I see… It is complicated, I think I will need to take some time reading it. Can you commit anything to trigger a vercel preview build?

I did create a video, how I was thinking it could work. TiddlyWiki5 Translatable Plugins 01 - YouTube

It also explains the pluginlibrary-server, which is part of TW now. … I think I should review the whole thing.

Also in the light of Translating TW documentation - workflow proposal … Which I think is interesting. … But I didn’t test this workflow yet. So I think we should have a closer look there too.

1 Like

Learn from usage in projetify and fishing plugins:

In the main plugin, transclude the text

caption: {{$:/language/fishing/discard}}
description: {{$:/language/fishing/discardtip}}

from a default en-GB language multid

Other languages like zh-Hans are provided via sub-plugin

In plugin.info, add main plugin as dependents , "dependents": "$:/plugins/oflg/fishing", so it appears as a sub-plugin.

The principle is the sub-plugin will overwrite tiddlers provided by main plugin, so language pack will overwrite the $:/language/fishing/discard in the main plugin.

1 Like

A note for myself, I can use [Intro] Multiline Field Editor Plugin - #10 by pmario to translate doc site of plugin Multilanguage TiddlyWiki - Any existing resources? - #34 by linonetwo

Hello @linonetwo,

Do you know if there is a way to define multitids in TiddlyWiki single html file version?

BR,

Eskha

1 Like

Sorry, I use nodejs wiki since 3 years ago. You may need to ask other experts in the forum .

I came up with this today:

Macro

title: $:/core/i18n/translate
tags: $:/tags/Macro

\define t(key) <$list filter="[[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]]" variable="lang"><$text text={{{[<lingo-base>addsuffix<lang>addsuffix[/]addsuffix<__key__>get[text]]}}} /></$list>

usage:

\define lingo-base() $:/language/linonetwo/daily-habit/

<<t "Habits">>

Localization

1 define languages in src/daily-habit/i18n/en-GB/Habit.multids and src/daily-habit/i18n/zh-Hans/Habit.multids

title: $:/language/linonetwo/daily-habit/en-GB/

Habits: Habits
title: $:/language/linonetwo/daily-habit/zh-Hans/

Habits: 习惯

Very simple. Should I add it to the core, do you think it is a good idea?

2 Likes

Hi @linonetwo extracting the name of the language from the title of the current language plugin is brittle. Better to get the value of $:/language, defaulting to “$:/languages/en-GB”, and then get the “name” field of that tiddler.

1 Like

A PR is here feat: t macro and docs by linonetwo · Pull Request #7821 · Jermolene/TiddlyWiki5 · GitHub

Hope we can end this pain that lasts for years…

1 Like