Skip to content

Translate and clone JSON files (node.js script)

License

Notifications You must be signed in to change notification settings

YU000jp/logseq-l10n-clone-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logseq-l10n-clone-json

Clone JSON files for Logseq full languages based on one translation file

Logseq full Language list

English Local Language
Afrikaans Afrikaans
German Deutsch
Spanish Español
French Français
Indonesian Bahasa Indonesia
Italian Italiano
Japanese 日本語
Korean 한국어
Norwegian Norsk
Dutch Nederlands
Polish Polski
Portuguese Português
Russian Русский
Slovak Slovenčina
Turkish Türkçe
Ukrainian Українська
Chinese Simplified 简体中文
Chinese Traditional 繁體中文

Dependencies

  • Use Microsoft Azure Cognitive Services Translation API
  • Use logseq-l10n: L10N framework for Logseq plugins

Install

  1. Clone this repo. Run command 'pnpm install' for dependencies.
  2. Edit config.js and change the API key etc. (Azure Portal)

Usage

  1. First, set up "logseq-l10n". Then, create one translation file.
  2. Enter the file name and path in config.js.
  3. Run “node index.cjs” command in terminal.
  4. Files will be created.

    If a file with the same name exists, it will not be updated.

  5. The sample code for importing the created translation files is as follows.
import { setup as l10nSetup } from "logseq-l10n" //https://github.com/sethyuan/logseq-l10n
import af from "./translations/af.json"
import de from "./translations/de.json"
import es from "./translations/es.json"
import fr from "./translations/fr.json"
import id from "./translations/id.json"
import it from "./translations/it.json"
import ja from "./translations/ja.json"
import ko from "./translations/ko.json"
import nbNO from "./translations/nb-NO.json"
import nl from "./translations/nl.json"
import pl from "./translations/pl.json"
import ptBR from "./translations/pt-BR.json"
import ptPT from "./translations/pt-PT.json"
import ru from "./translations/ru.json"
import sk from "./translations/sk.json"
import tr from "./translations/tr.json"
import uk from "./translations/uk.json"
import zhCN from "./translations/zh-CN.json"
import zhHant from "./translations/zh-Hant.json"

const main = async () => {
await l10nSetup({
    builtinTranslations: {//Full translations
    af, de, es, fr, id, it, ja, ko, "nb-NO": nbNO, nl, pl, "pt-BR": ptBR, "pt-PT": ptPT, ru, sk, tr, uk, "zh-CN": zhCN, "zh-Hant": zhHant
    }
})

}

Recommend

  1. Generate JSON file for translation > logseq-l10n-generate-json: Extract ' t("string") ' from the scripts in the folder and create one JSON file.