插件应用市场
MyLibreTranslate
本地离线翻译
# 功能
- 无需网络,基于LibreTranslate的本地翻译
- 通过检测剪贴板,进行翻译。
- 选中后复制译文
# 配置
1. 使用关键字 setting、翻译设置打开设置
![](img/Snipaste_2024-12-02_11-47-09.png)
2. 点击初始配置,然后点击导出配置,即可在下载目录下找到配置文件`MyLibreTranslate.json`。
port: 启动的端口
host: 启动的host
url_prefix: 访问路径前缀
libretranslate_path: LibreTranslate的安装路径
parsed: 自定义格式-应用于翻译-变量模式下
parsed.camelCase: 自定义格式名
parsed.func: 自定义格式的函数,固定输入参数为`words` ,返回参数为处理后字符串,如需添加,请按格式书写,
```json
{
"port": "5000",
"host": "127.0.0.1",
"url_prefix": "/mylibre",
"libretranslate_path": "D:\\APP\\devAPP\\python\\envs\\py38-LibreTranslate\\Scripts\\libretranslate.exe",
"parsed": {
"camelCase": {
"description": "驼峰式命名(camelCase)",
"func": "(words) => words.map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('')"
},
"pascalCase": {
"description": "帕斯卡式命名(PascalCase)",
"func": "(words) => words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join('')"
},
"snake_case": {
"description": "下划线分隔命名(snake_case)",
"func": "(words) => words.join('_')"
},
"kebab_case": {
"description": "破折号分隔命名(kebab-case)",
"func": "(words) => words.join('-')"
},
"space_case": {
"description": "分词分隔命名(space case)",
"func": "(words) => words.join(' ')"
},
"english_title": {
"description": "英文标题(English Title)",
"func": "(words) => words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')"
},
"object_properties": {
"description": "对象属性(object.properties)",
"func": "(words) => words.join('.')"
},
"file_path": {
"description": "文件路径(file/path)",
"func": "(words) => words.join('/')"
},
"constant_underscore_case": {
"description": "常量-下划线(CONSTANT_CASE)",
"func": "(words) => words.join('_').toUpperCase()"
},
"constant_kebab_case": {
"description": "常量-破折号(CONSTANT-CASE)",
"func": "(words) => words.join('-').toUpperCase()"
}
}
}
```
3. 输入关键字 `start_translation`、`翻译启动`启动程序
建议先单独启动成功后在使用插件启动
`${libretranslate_path} --load-only zh,en --port ${_translation_port} --url-prefix ${_url_prefix}`
4. 翻译 选择翻译文本 启动utools超级面板 `翻译`或者`翻译(变量)`
![](img/Snipaste_2024-12-02_11-57-59.png)
`翻译`:中译英、或者英译中
点击即可复制翻译结果
![](img/Snipaste_2024-12-02_12-00-19.png)
`翻译(变量)`:中译英(变量模式)、或者英译英(变量模式)
点击即可复制翻译结果
![](img/Snipaste_2024-12-02_12-01-23.png)
# 依赖项
**可用的LibreTranslate API**
- 按照官网指导进行部署:[LibreTranslate/LibreTranslate: Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup.](https://github.com/LibreTranslate/LibreTranslate)
- 无需网络,基于LibreTranslate的本地翻译
- 通过检测剪贴板,进行翻译。
- 选中后复制译文
# 配置
1. 使用关键字 setting、翻译设置打开设置
![](img/Snipaste_2024-12-02_11-47-09.png)
2. 点击初始配置,然后点击导出配置,即可在下载目录下找到配置文件`MyLibreTranslate.json`。
port: 启动的端口
host: 启动的host
url_prefix: 访问路径前缀
libretranslate_path: LibreTranslate的安装路径
parsed: 自定义格式-应用于翻译-变量模式下
parsed.camelCase: 自定义格式名
parsed.func: 自定义格式的函数,固定输入参数为`words` ,返回参数为处理后字符串,如需添加,请按格式书写,
```json
{
"port": "5000",
"host": "127.0.0.1",
"url_prefix": "/mylibre",
"libretranslate_path": "D:\\APP\\devAPP\\python\\envs\\py38-LibreTranslate\\Scripts\\libretranslate.exe",
"parsed": {
"camelCase": {
"description": "驼峰式命名(camelCase)",
"func": "(words) => words.map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('')"
},
"pascalCase": {
"description": "帕斯卡式命名(PascalCase)",
"func": "(words) => words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join('')"
},
"snake_case": {
"description": "下划线分隔命名(snake_case)",
"func": "(words) => words.join('_')"
},
"kebab_case": {
"description": "破折号分隔命名(kebab-case)",
"func": "(words) => words.join('-')"
},
"space_case": {
"description": "分词分隔命名(space case)",
"func": "(words) => words.join(' ')"
},
"english_title": {
"description": "英文标题(English Title)",
"func": "(words) => words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')"
},
"object_properties": {
"description": "对象属性(object.properties)",
"func": "(words) => words.join('.')"
},
"file_path": {
"description": "文件路径(file/path)",
"func": "(words) => words.join('/')"
},
"constant_underscore_case": {
"description": "常量-下划线(CONSTANT_CASE)",
"func": "(words) => words.join('_').toUpperCase()"
},
"constant_kebab_case": {
"description": "常量-破折号(CONSTANT-CASE)",
"func": "(words) => words.join('-').toUpperCase()"
}
}
}
```
3. 输入关键字 `start_translation`、`翻译启动`启动程序
建议先单独启动成功后在使用插件启动
`${libretranslate_path} --load-only zh,en --port ${_translation_port} --url-prefix ${_url_prefix}`
4. 翻译 选择翻译文本 启动utools超级面板 `翻译`或者`翻译(变量)`
![](img/Snipaste_2024-12-02_11-57-59.png)
`翻译`:中译英、或者英译中
点击即可复制翻译结果
![](img/Snipaste_2024-12-02_12-00-19.png)
`翻译(变量)`:中译英(变量模式)、或者英译英(变量模式)
点击即可复制翻译结果
![](img/Snipaste_2024-12-02_12-01-23.png)
# 依赖项
**可用的LibreTranslate API**
- 按照官网指导进行部署:[LibreTranslate/LibreTranslate: Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup.](https://github.com/LibreTranslate/LibreTranslate)