1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-26 17:06:51 +00:00

Add example startup action to switch to browser language

This commit is contained in:
Jermolene 2019-03-07 18:45:52 +00:00
parent 2c2d03f7a7
commit f047e7cbf5
2 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,4 @@
title: $:/_Startup/SetLanguage
tags: $:/tags/StartupAction
<$action-setfield $tiddler="$:/language" text={{{ [[$:/languages/en-GB]] [plugin-type[language]sort[description]removeprefix[$:/languages/]] +[prefix{$:/info/browser/language}] ~[[en-GB]] +[addprefix[$:/languages/]] }}}/>

View File

@ -1,10 +1,10 @@
created: 20180323092308399
modified: 20180323092547312
modified: 20190307183936035
tags: Features
title: StartupActions
type: text/vnd.tiddlywiki
During startup, TiddlyWiki executes any ActionWidgets found in tiddlers with the following system tags:
TiddlyWiki executes any ActionWidgets found in tiddlers with the following system tags during startup:
* <<tag "$:/tags/StartupAction">> (executed on all platforms)
* <<tag "$:/tags/StartupAction/Browser">> (only executed when running in the browser)
@ -22,6 +22,12 @@ Startup actions are useful for customising TiddlyWiki according to environmental
</$reveal>
```
<<.from-version "5.1.20">> This example switches to the language plugin matching the language reported by the browser:
```
<$action-setfield $tiddler="$:/language" text={{{ [[$:/languages/en-GB]] [plugin-type[language]sort[description]removeprefix[$:/languages/]] +[prefix{$:/info/browser/language}] ~[[en-GB]] +[addprefix[$:/languages/]] }}}/>
```
Note that global macros are not available within startup action tiddlers by default. If you need to access them then you'll need to explicitly include them with an ''import'' [[pragma|Pragma]] at the top of the tiddler:
```