/extract-i18n

Extrac characters and generate i18n file

Primary LanguageJavaScript

Extract i18n

Commitizen friendly

Extract characters, translate and generate i18n file

Usage

shift + command/ctrl + p to search command

Setting

Commands

content is selection content

Extract Text

Replace only the selected string (automatically includes the immediate quotation marks)

  • <div>Dashboard Title</div>
    • <div>t("extract-i18n.dashboardTitle")</div>
  • <div>"Dashboard Title"</div>
    • <div>t("extract-i18n.dashboardTitle")</div>
  • <div>'Dashboard Title'</div>
    • <div>t("extract-i18n.dashboardTitle)</div>

Extract Text With Auto Brace Wrapper

Replace the selected string (automatically includes the immediate quotation marks) and auto wrapper the {}

  • <div>Dashboard Title</div>
    • <div>{t("extract-i18n.dashboardTitle")}</div>
  • <div>{"Dashboard Title"}</div>
    • <div>{t("extract-i18n.dashboardTitle")}</div>
  • <div>"Dashboard Title"</div>
    • <div>{t("extract-i18n.dashboardTitle")}</div>
  • <div>'Dashboard Title'</div>
    • <div>{t("extract-i18n.dashboardTitle)}</div>
  • <div title="Dashboard Title" />
    • <div title={t("extract-i18n.dashboardTitle)} />

Extract Modify Prefix:

Modify the key prefix

This is default replace content:

t("extract-i18n.dashboardTitle)

Modify default value extract-i18n -> dashboards

The new replacement will look like this:

t("dashboards.dashboardTitle)

Extract Modify Target

The specified JSON file is generated in the nearest Locales directory,

eg: ["en","zh"] -> **/locales/en.json, **/locales/zh.json

Extract Modify langsMap

The target's value (zh) maybe is not a keyword for translate api, it should be zh-CN

Extract Modify Template

default value: t("{{key}}")

Extract Engine

default is use bing-translate-api you can choose use custom service eg:

Extract CustomUrl

if engine is custom, translate will through this api to get result request: fetch("${custom}?to=en&text=你好", { method: 'GET' }).then(response => response.text())