Multi language content

Hello,

I want to present a summary of a multilingual content TW.
It was only possible by a lot of support from this community. THANK YOU
In my use case the TW will be used by the users of different countries.
As in wikipedia some of the content tiddlers are available in other languages some not.
Or main language is English.
The user should get the right tiddler by changing the flag in TW.

To realize our behavior, we have defined a tiddler as decision maker.
This tiddler contain the information if other translations are available and the respective translated content will be shown.

Here an example:

We are describing an organization:

The decision maker tiddler is named org and looks like:

author: This is a placeholder
de-DE: Org-Ge
en-GB: Org-En
title: Org

<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$list filter="[<currentTiddler>has<selected-language>get<selected-language>]"  emptyMessage="no translation for {{$:/language}}" variable="thislanguage" ><$transclude tiddler=<<thislanguage>> mode="block" />
</$list>
</$list>

The fields de-DE and en-GB contain the information about the tiddler with the translated content. The fields need to be named in the same way as it is defined in TW.

author: The Team from Germany
caption: Die Organisation
title: Org-Ge

Hier wird die Organisation vorgestellt
author: The US Team
caption: The Organization
title: Org-En

The organization is introduced here

If the user select the English Flag the text from Org-En will be displayed in the German Flag the text from Org-Ge.

In the future we will extend it to French, Spain, Italy, and other languages also.

Additionally, the author information will be shown of the translated tiddler if this here is available.

tags: $:/tags/ViewTemplate/Subtitle
title: $:/core/ui/ViewTemplate/subtitle/modifier

<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$link to={{{[<currentTiddler>has<selected-language>get<selected-language>has[author]get[author]] :else[<currentTiddler>has[author]get[author]] :else[get[modifier]] }}}/>
</$list>

Also it was requested to have the caption instead of the title in the story line if available.
To exchange the title by the caption $:/_/my/config/ViewTemplateTitleFilters/caption and $:/_/my/core/ui/ViewTemplate/title/caption was edited as followed.
See here the origin post : - Talk TW](Display the caption field instead of the tiddler title in story line)

title: $:/_/my/config/ViewTemplateTitleFilters/caption
tags: $:/tags/ViewTemplateTitleFilter
list-before: $:/config/ViewTemplateTitleFilters/default

[<currentTiddler>has[caption]then[$:/_/my/core/ui/ViewTemplate/title/caption]]
title: $:/_/my/core/ui/ViewTemplate/title/caption

<h2 class="tc-title">{{!!caption}}</h2>

To have the right header also in the Story Line if the translation function is used also [$:/core/ui/ViewTemplate/title/default] also changed to this code here.

\whitespace trim
<h2 class="tc-title">
<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$link to={{{[<currentTiddler>has<selected-language>get<selected-language>has[caption]get[caption]] 
:else[<currentTiddler>has<selected-language>get<selected-language>has[title]get[title]]
:else[<currentTiddler>has[caption]get[caption]]
:else[<currentTiddler>has[title]get[title]] }}}/>
</$list>
</h2>

Actually, this is working and accepted by the users.

OUTLOOK

  1. *** SOLVED*** Today the title or the caption of the main tiddler is not changing. In the example Org. There is a work around existing what is changing the content of the field caption with the title but in some cases it is failing. Our standard is this here Display the caption field instead of the tiddler title in story line - Discussion - Talk TW
  2. The team is discussing to have an overview of existing languages for each tiddler so the user can change to a language if the specific information is not available in the selected version.
  3. Implement translation services. But the most one are failing due to fact that the formatting will be destroyed. An idea is to develop something like <$translate “This is the organization” service=“deepl.com” source=“en” target=“ge”> will call the api and return the translated text.

Hopefully this was helpful for others who have to deal with multilingual content.
I will update here my progress :slight_smile:

Stefan

3 Likes

Hi, we already implemented this before, see feat: t macro and docs by linonetwo · Pull Request #7821 · TiddlyWiki/TiddlyWiki5 · GitHub

It was quite simple

\procedure lingo(title,override-lingo-base)
<!-- Lingo procedure -->
<!-- Get the parse mode used to invoke this procedure -->
<$parameters $parseMode="parseMode">
	<!-- Compute the lingo-base-->
	<$let active-lingo-base={{{ [<override-lingo-base>!match[]else<lingo-base>] }}}>
		<!-- First try the old school <active-lingo-base><title> format -->
		<$transclude $tiddler={{{ [<active-lingo-base>addsuffix<title>] }}} $mode=<<parseMode>>>
			<!-- If that didn't work, try the new <lingo-base><langcode>/<title> format -->
			<$let language-code={{{  [[$:/language]get[text]get[name]else[en-GB]] }}}>
        <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/>
			</$let>
		</$transclude>
	</$let>
</$parameters>
\end lingo

there are many documentation on that PR.

But later we decide to switch to other options, and it is pending till now feat: i18n framework based on extracting translations from plugin's /languages/ to /language/ by linonetwo · Pull Request #8435 · TiddlyWiki/TiddlyWiki5 · GitHub

Please have a look and push this to be a core feature, thanks.

P.S. an example of multi-lingo site is intention-tower-knowledge-graph/wiki/tiddlers/language at master · tiddly-gittly/intention-tower-knowledge-graph · GitHub

2 Likes

Hi @linonetwo,

I am not sure to understand you right and how to use your solution instead of the implementation we use.
Honestly, I am not able to understand how I should support here. :’(
Is there a guideline or similar existing?
How not exiting translations are handled?

Stefan