Field selection by $:/language

Hi Experts,

I am working to find a solution for a wiki with different languages.
One of my Ideas is to put the information I want to show in different Tiddlers.
Than to select them by the $:/language and the information in the fields set in the in the Tiddler.
Ok, sounds strange. Here the Tiddler what is “selectiing”

de-DE: Tiddler (Deutsch)
en-GB: Tiddler (English)
modified: 20240516073947457
modifier: cISMS Team
tags: 
title: Result

Display here the Tiddler (Deutsch) if Language is set to de-DE or Tiddler (English) if Language is en-GB and other ....

And here the content Tiddlers

title: Tiddler (English)

This is English
title: Tiddler (Deutsch)

Dies ist Deutsch

I hope someone is able to help here, or to offer another solution.

Stefan

Hi. Have a look at my (partial) solution here: https://avs-monthly-report.tiddlyhost.com/

Click on the parameters tab, then on main parameters, finally change the language (in two ways : 1) only for this app; 2) for the whole TW if you check the checkbox)

All the non TW sentences in a tiddler are replaced by a field name:

<$button>Click me</$button>

is replaced by:

<$button>{{!!btn_lbl_clickme}}</$button>

Add a field named btn_lbl_clickme with the desired value.

The changes are done in LANG_English_en_GB and LANG_Français_fr_FR tiddlers.

Hoping this helps you

Hi @FRDV,

that is not solving my problem.
I don’t want to have a button or similar.
If the tiddler will be selected the repective content from the Tiddler, named in the field, selected by the language, should be displayed.

Stefan

Hi Stefan,
You may have a closer look at my multiline-field editor in combination with field-search and the fields-visibility plugin.

See: Wikilabs Home — A home for: Plugins, Editions and Themes! and the intro video at: https://www.youtube.com/watch?v=aibEiFJvlNk

Intro thread here at talk: [Intro] Multiline Field Editor Plugin

Hi @pmario,

nice idea but I think my users are unable to handle it especially by adding content and searching.
I am still looking for a possibility I described :laughing:

Stefan

Tell me if this is what you want:

<$list filter="[<currentTiddler>get[de_DE]]" emptyMessage={{Tiddler (English)}}>{{Tiddler (Deutsch)}}</$list>

<$list filter="[<currentTiddler>get[fr_FR]]" emptyMessage={{Tiddler (English)}}>{{Tiddler (Français)}}</$list>

<$list filter="[<currentTiddler>get[it_IT]]" emptyMessage={{Tiddler (English)}}>{{Tiddler (Italiano)}}</$list>

Any non existing field give the English one

EDIT: Oops… I forgot you wanted this in relation with $:/language.

you can see my attempt here: https://learning-math.tiddlyhost.com

Relevant tiddlers: Learning math — My notes on learning math

Hi @FRDV,

do you have also an idea to select the filter from the $./language setting?
My target is that the user select only once the language and the content will be selected automatically.

Stefan

Hi @telumire,

good idea, but my target is that the user select only once the language and the content will be selected automatically.

Stefan

1 Like

I’m searching a solution, right now I have this :

<$list filter="[all[tiddlers+system+shadows]field:plugin-type/language/] +[removeprefix[$:/languages/]]" variable="available-languages">

<<available-languages>>
</$list>

You might also have a look at $:/snippets/languageswitcher

Hi @FRDV,

Excellent! This is separating the right name of the field.
How to get it in “{{ }}” brakets to get the content from the “Tiddler name” in the field?

I think there will be a solution :slight_smile:

Stefan

hi @stefan_from_germany I believe this is a job for ViewTemplate cascades:

Create a tiddler tagged with $:/tags/ViewTemplateBodyFilter, with the following text field:

       [fields[]] 
:filter[{$:/language}removeprefix[$:/languages/]match<currentTiddler>] 
   :map[<..currentTiddler>get<currentTiddler>] 

and a list-before field with an empty value.

That should be enough to fulfill your purpose:

  1. The $:/tags/ViewTemplateBodyFilter blesses your filter as a cascading ViewTemplateBody filter
  2. The empty list-before field puts your filter tiddler on top of the cascade
  3. The text field defines a filter that searches for a field in your main “selection” tiddler that matches the language set in $:/language. If it finds one, the filter result is set to the value of the matching field, otherwise the cascade goes on with the next ViewTemplateBodyFilter.
1 Like

Finally I made it!

Create a field for each language you have a translation

field de-DE value Tiddler (Deutsch)
field en-GB value Tiddler (English)
field fr-FR value Tiddler (Français)

NOTE:

  • use the dash - between the letters, not the underscore _

  • [[$:/languages/en-GB]] at the beginning of the filter forces the default language in the list

<$list filter="[[$:/languages/en-GB]] [all[tiddlers+system+shadows]field:plugin-type/language/] +[removeprefix[$:/languages/]]" variable="available-languages">

<<available-languages>> <!-- for demo purpose -->

<$list filter="[<currentTiddler>has<available-languages>get<available-languages>]" variable="thislanguage" >

<$transclude tiddler=<<thislanguage>> />

</$list>
</$list>

Code works in the Tiddler (Whatever)

Have fun!

Added emptyMessage="no translation", just for the fun of it

<$list filter="[[$:/languages/en-GB]] [all[tiddlers+system+shadows]field:plugin-type/language/] +[removeprefix[$:/languages/]]" variable="available-languages">

<<available-languages>> <!-- for demo purpose -->

<$list filter="[<currentTiddler>has<available-languages>get<available-languages>]" emptyMessage="no translation" variable="thislanguage" >

<$transclude tiddler=<<thislanguage>> />

</$list>
</$list>

Hi @FRDV,

thank you for your support.
What is ti I am doing wrong here.
I only want to see der german or english tiddler. Not all of them :cry:

Here is the code i am using

<$list filter="[[$:/languages/en-GB]] [all[tiddlers+system+shadows]field:plugin-type/language/] +[removeprefix[$:/languages/]]" variable="available-languages">

<$list filter="[<currentTiddler>has<available-languages>get<available-languages>]" emptyMessage="no translation" variable="thislanguage" >

<$transclude tiddler=<<thislanguage>> />

</$list>
</$list>

And here the result

This is English

Dies ist Deutsch

So both Tiddlers are displayed not only the one of the setting in language.

Can you help me here to change it to display only the right tiddler?

Stefan

Hi Stefan

For the languages you don’t want to see you only have to:

  • delete the unwanted field
  • give NO value to the unwanted field, ie. leaving it empty

Hi @FRDV,

hopefully not :slight_smile:
What I am looking for is, the possibility if a user is switching from english to german (or an other language), the content will change automatically, not to have all available langauges displayed the same time.

Is that possible?

Thx
Stefan

This should do the trick

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

EDIT: changed the emptyMessage to indicate the language of a missing translation

NOTES:

you can change

  • {$:/language!!text} to {$:/language} (same thing but shorter)
  • all available-languages to available-language (because there is only one language)

Core feature: feat: t macro and docs by linonetwo · Pull Request #7821 · Jermolene/TiddlyWiki5 · GitHub

Just use lingo precedure, see Docs in Preview site