logseq-l10n
L10N framework for Logseq plugins.
How to use it
import "@logseq/libs"
import { setup, t } from "logseq-l10n"
import zhCN from "./translations/zh-CN.json"
logseq
.ready(async () => {
const l10nSetup = setup({
urlTemplate:
"https://raw.githubusercontent.com/sethyuan/logseq-plugin-doc/master/src/translations/${locale}.json",
builtinTranslations: { "zh-CN": zhCN },
})
await l10nSetup
console.log(t("Hello world!"))
console.log(t("Hello ${name}!", { name: "world" }))
})
.catch(console.error)
{
"Hello world!": "你好世界!",
"Hello ${name}!": "你好${name}!"
}
For a referential plugin implementation, please see logseq-plugin-doc.
In the simplest case, you only need to give a urlTemplate
to setup
. Users then can contribute translations in the form of PR, and when you merge them, the translations will be available for use immediately for future fetches.