Created
April 10, 2026 07:34
-
-
Save appare45/95977ed9e037ee1d57a14737f65bcdb9 to your computer and use it in GitHub Desktop.
Typstで多言語対応したいときに見る
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #let t(it) = { | |
| if type(it) == dictionary { | |
| context it.at(text.lang, default: it.at(it.keys().first())) | |
| } else { | |
| it | |
| } | |
| } | |
| #let hoge = ( | |
| ja: "日本語", | |
| en: "English", | |
| ) | |
| #set text(lang: ja) | |
| #t(hoge) // => 日本語 | |
| #set text(lang: en) | |
| #t(hoge) // => English |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment