From fc99400e3c190c2a5402b28901e20b37a19c7e8b Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Mon, 17 Jun 2024 18:15:45 +0800 Subject: [PATCH 1/3] fix: When current language don't have translation, fallback to English --- core/wiki/macros/lingo.tid | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/wiki/macros/lingo.tid b/core/wiki/macros/lingo.tid index 24d451b0314..4da910625a8 100644 --- a/core/wiki/macros/lingo.tid +++ b/core/wiki/macros/lingo.tid @@ -15,8 +15,12 @@ $:/language/ <$transclude $tiddler={{{ [addsuffix] }}} $mode=<<parseMode>>> <!-- If that didn't work, try the new <lingo-base><langcode>/<title> format --> + <!-- Get active language, if not language is selected, fallback to English --> <$let language-code={{{ [[$:/language]get[text]get[name]else[en-GB]] }}}> - <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/> + <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>> + <!-- When current language don't have translation, fallback to English --> + <$transclude $tiddler={{{ [<active-lingo-base>addsuffix[en-GB]addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/> + </$transclude> </$let> </$transclude> </$let> From f8e07ff5b78772ca97ba3d6c2ce8869fdf8d85e2 Mon Sep 17 00:00:00 2001 From: lin onetwo <linonetwo012@gmail.com> Date: Mon, 17 Jun 2024 18:42:04 +0800 Subject: [PATCH 2/3] feat: allow fallback to depended language --- core/wiki/macros/lingo.tid | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/wiki/macros/lingo.tid b/core/wiki/macros/lingo.tid index 4da910625a8..6e84ce41b38 100644 --- a/core/wiki/macros/lingo.tid +++ b/core/wiki/macros/lingo.tid @@ -18,8 +18,13 @@ $:/language/ <!-- Get active language, if not language is selected, fallback to English --> <$let language-code={{{ [[$:/language]get[text]get[name]else[en-GB]] }}}> <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>> - <!-- When current language don't have translation, fallback to English --> - <$transclude $tiddler={{{ [<active-lingo-base>addsuffix[en-GB]addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/> + <!-- Fallback to its first dependent, like "de-AT" will fallback to "de-DE" in some cases --> + <$let language-code={{{ [[$:/languages/]addsuffix<language-code>get[dependents]removeprefix[$:/languages/]first[]] }}}> + <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>> + <!-- When current language and its dependent don't have translation, fallback to English --> + <$transclude $tiddler={{{ [<active-lingo-base>addsuffix[en-GB]addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/> + </$transclude> + </$let> </$transclude> </$let> </$transclude> From e9568720489ae5fe9ee74cd16330b8168028beff Mon Sep 17 00:00:00 2001 From: lin onetwo <linonetwo012@gmail.com> Date: Tue, 18 Jun 2024 01:25:57 +0800 Subject: [PATCH 3/3] Update lingo.tid --- core/wiki/macros/lingo.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/wiki/macros/lingo.tid b/core/wiki/macros/lingo.tid index 6e84ce41b38..183d305eb31 100644 --- a/core/wiki/macros/lingo.tid +++ b/core/wiki/macros/lingo.tid @@ -19,7 +19,7 @@ $:/language/ <$let language-code={{{ [[$:/language]get[text]get[name]else[en-GB]] }}}> <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>> <!-- Fallback to its first dependent, like "de-AT" will fallback to "de-DE" in some cases --> - <$let language-code={{{ [[$:/languages/]addsuffix<language-code>get[dependents]removeprefix[$:/languages/]first[]] }}}> + <$let language-code={{{ [[$:/languages/]addsuffix<language-code>get[dependents]removeprefix[$:/languages/]] }}}> <$transclude $tiddler={{{ [<active-lingo-base>addsuffix<language-code>addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>> <!-- When current language and its dependent don't have translation, fallback to English --> <$transclude $tiddler={{{ [<active-lingo-base>addsuffix[en-GB]addsuffix[/]addsuffix<title>] }}} $mode=<<parseMode>>/>