https://github.com/lujun9972/youdao.sh
简单的调用有道智云文本翻译API进行翻译的脚本.
https://github.com/lujun9972/youdao.sh
Last synced: 12 months ago
JSON representation
简单的调用有道智云文本翻译API进行翻译的脚本.
- Host: GitHub
- URL: https://github.com/lujun9972/youdao.sh
- Owner: lujun9972
- Created: 2019-09-01T23:18:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-04T09:27:24.000Z (almost 7 years ago)
- Last Synced: 2025-02-09T15:11:53.167Z (over 1 year ago)
- Language: Shell
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
#+TITLE: README
#+AUTHOR: lujun9972
#+TAGS: youdao.sh
#+DATE: [2019-09-03 二 19:15]
#+LANGUAGE: zh-CN
#+STARTUP: inlineimages
#+OPTIONS: H:6 num:nil toc:t \n:nil ::t |:t ^:nil -:nil f:t *:t <:nil
简单的调用有道智云文本翻译API进行翻译的脚本.
* feature
+ 允许自定义显示模板
+ 允许自定义从json结果中抽取域值的filter
* Requirements
+ jq
+ curl
* Usage
1. 在 =youdao.cfg= 中配置变量名和从json结果中抽取域值的filter的对应关系
#+BEGIN_SRC conf
errorCode=.errorCode
query=.query
translation=.translation[0]
speakUrl=.speakUrl
#+END_SRC
其中filter需要遵循 =jq= 命令的filter规则
2. 在 =youdao.template= 中配置显示模板,其中可以用shell格式嵌入 =youdao.cfg= 中配置好的变量
#+BEGIN_EXAMPLE
翻译结果: ${translation}
#+END_EXAMPLE
3. 使用 =youdao.sh 翻译= 查询结果
#+BEGIN_SRC shell :results org
./youdao.sh hello world
#+END_SRC
#+RESULTS:
#+BEGIN_SRC org
翻译结果: 你好,世界
#+END_SRC