Plug-ins
Plug-ins can be configured in .i18n/conf.yml
, such as:
addon:
- i18n.addon/toc
Official Plug-ins
i18n.addon/toc
: Table of Contents
Generates a json
table of contents based on TOC
, enabled by default
i18n.addon/mouse
: Mouse Effects
File Name Convention
Plug-ins are all npm
packages.
The package corresponding to i18n.addon/toc
above is https://www.npmjs.com/package/@i18n.addon/toc.
The plugin uses the latest version by default and checks for updates weekly.
If you want to fix the version, you can write i18n.addon/[email protected]
.
The translation command line i18n.site
will install the agreed-upon files of the plug-in package and then execute them.
The agreed file names are as follows:
htmIndex.js
htmIndex.js
will be injected at the end of .i18n/htm/index.js
.
__CONF__
will be replaced with the name of the current configuration (e.g., dev
or ol
).
afterTran.js
It will be called after the translation is completed, and the parameters passed in are as follows:
lang_li
: Language list, the first language is the source languagechanged
: Modified filesroot
: Project root directory
The return value is a dictionary, for example:
{
file:{
// path: txt, for example :
// "_.json": "[]"
}
}
file
: Output file list, path
: File path, txt
: File content.
Built-in Functions
The built-in js
runtime is based on boa and has the following built-in functions:
wPath(path, txt)
: Write to filerTxt(path)
: Read text filerBin(path)
: Read binary filerDir(dirpath)
: Read the directory, returning an array containing the directory list and file list
Development Guide
Plug-in development can refer to https://github.com/i18n-site/addon