UNPKG

6.15 kBMarkdownView Raw
1# translate .md to \*.md [![explain](http://llever.com/explain.svg)](https://github.com/chinanf-boy/explain-translateMds) [![install size](https://packagephobia.now.sh/badge?p=translate-mds)](https://packagephobia.now.sh/result?p=translate-mds)
2
3like
4
5```bash
6.md to .「all-language」.md
7```
8
9[english](./README.en.md)
10
11---
12
13[![Build Status](https://travis-ci.org/chinanf-boy/translate-mds.svg?branch=master)](https://travis-ci.org/chinanf-boy/translate-mds)
14[![codecov](https://codecov.io/gh/chinanf-boy/translate-mds/branch/master/graph/badge.svg)](https://codecov.io/gh/chinanf-boy/translate-mds)
15[![GitHub license](https://img.shields.io/github/license/chinanf-boy/translate-mds.svg)](https://github.com/chinanf-boy/translate-mds/blob/master/License)
16![npm](https://img.shields.io/npm/v/translate-mds.svg)
17![GitHub release](https://img.shields.io/github/tag/chinanf-boy/translate-mds.svg)
18
19## 生活
20
21[help me live , live need money 💰](https://github.com/chinanf-boy/live-need-money)
22
23---
24
25<!-- START doctoc generated TOC please keep comment here to allow auto update -->
26<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
27
28- [这个项目是 为了 所有-的-markdown-编写-文件 📃 翻译 的 `工具`](#%E8%BF%99%E4%B8%AA%E9%A1%B9%E7%9B%AE%E6%98%AF-%E4%B8%BA%E4%BA%86-%E6%89%80%E6%9C%89-%E7%9A%84-markdown-%E7%BC%96%E5%86%99-%E6%96%87%E4%BB%B6--%E7%BF%BB%E8%AF%91-%E7%9A%84-%E5%B7%A5%E5%85%B7)
29- [Demo](#demo)
30- [命令行选项](#%E5%91%BD%E4%BB%A4%E8%A1%8C%E9%80%89%E9%A1%B9)
31- [My-translate-list](#my-translate-list)
32- [常见问题](#%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
33 - [1. 有时会抽风会卡住,停滞](#1-%E6%9C%89%E6%97%B6%E4%BC%9A%E6%8A%BD%E9%A3%8E%E4%BC%9A%E5%8D%A1%E4%BD%8F%E5%81%9C%E6%BB%9E)
34 - [2. 没翻译成功的有 数量/总数](#2-%E6%B2%A1%E7%BF%BB%E8%AF%91%E6%88%90%E5%8A%9F%E7%9A%84%E6%9C%89-%E6%95%B0%E9%87%8F%E6%80%BB%E6%95%B0)
35- [Tips](#tips)
36 - [欢迎 👏 ISSUE 和 PULL](#%E6%AC%A2%E8%BF%8E--issue-%E5%92%8C-pull)
37- [特性](#%E7%89%B9%E6%80%A7)
38- [已分隔的代码](#%E5%B7%B2%E5%88%86%E9%9A%94%E7%9A%84%E4%BB%A3%E7%A0%81)
39
40<!-- END doctoc generated TOC please keep comment here to allow auto update -->
41
42## 这个项目是 为了 所有-的-markdown-编写-文件 📃 翻译 的 `工具`
43
44```js
45npm install -g translate-mds
46```
47
48```js
49// all folder·
50translateMds md/
51
52//or single file
53
54translateMds test.md
55```
56
57## Demo
58
59![demo](./imgs/demo.gif)
60
61## 命令行选项
62
63```bash
64 translate [folder/single] md file language to you want
65
66 Usage
67 $ translateMds [folder/file name] [options]
68
69 Example
70 $ translateMds md/
71
72 [options]
73 -a API : default < baidu > {google|baidu|youdao}
74 -f from : default < auto 检验 >
75 -t to : default < zh >
76 -N num : default < 1 > {并发 数}
77 -R rewrite : default < false > {yes/no 重新写入翻译}
78
79 🌟[high user options]❤️
80
81 -D debug
82 -C cache : default: false 是否存储结果
83 -G google.com : default < false > { cn => Google.com 的 api }
84 -F force : default < false > { 当, 翻译的结果达不到 100%, 强行写入翻译文件 }
85 -M match : default [ ". ", "! "//...] {match this str, merge translate result }
86 -S skips : default ["... ", "etc. ", "i.e. "] {match this str will, skip merge translate result}
87 -T types : default ["html", "code"] {过滤 AST 类型, 不翻译}
88 --timewait : default: 80 { 每次请求的等待 80ms 时间}
89 --values [path] : default: false {取出原文中需要翻译的文本,放入path文件} [single file])
90 --translate [path] : default: false {使用此path文件替代请求网络翻译, 可搭配--values使用} [single file]
91 --text-glob [pattern] : default: false {文本匹配glob模式, 才能被翻译}
92 --no-disk : default: false {do not use cached Result}
93 --cache-name [filename]: : default: "translateMds" 存储的文件名
94 --glob [pattern] : default: false {文件匹配glob模式, 才能被翻译}
95 --ignore [relative file/folder] : default: false {忽略 文件/文件夹 字符串匹配, 可用`,`分隔多路径 }
96```
97
98---
99
100## My-translate-list
101
102[项目测试翻译列表](https://github.com/chinanf-boy/translate-mds-test-list) or
103[更多中文 🇨🇳 翻译列表](https://github.com/chinanf-boy/chinese-translate-list)
104
105## 常见问题
106
107### 1. 有时会抽风会卡住,停滞
108
109```js
110If slow , may be you should try again or use -D
111```
112
113问题来自 API, 你只要再运行.
114
115### 2. 没翻译成功的有 数量/总数
116
117> 数量是 没有翻译成功/总数是 单个文件翻译总数
118
119出现这样的问题, 一般是来自 不常见符号/或句子过长 导致的 字符移位.
120
121这个时候, 你可以使用 `-D` 调试 / `-F` 强制写入文件 / 调整不常见的字符
122
123[具体可看](https://github.com/chinanf-boy/translate-mds/issues/22)
124
125## Tips
126
1271. 不同的文件格式, 使用[pandoc 转换看看](https://github.com/jgm/pandoc)
1282. 不要`-f **`指定语言,`translation.js`会自动检测
129
130- `--timewait [number]` 可以拉长每次请求翻译的时间, 减少被禁 ip
131- `--values [file-path]` (单个文件使用) 获得将要翻译的原本输出文件
132- `--translate [file-path]` (单个文件使用) 取代请求 api, 改为使用此文件的翻译内容
133
134### 欢迎 👏 ISSUE 和 PULL
135
136## 特性
137
138- [x] 提高 http 之类的 md 格式准确率
139- [x] 自动换 翻译源
140- [x] 启用 md AST
141
142## 已分隔的代码
143
144- [files-list](https://github.com/chinanf-boy/files-list)
145- [what-time](https://github.com/chinanf-boy/what-time)
146- [zh-to-en-symbol](https://github.com/chinanf-boy/zh-to-en-symbol)
147
148---
149
150使用 [`remark`](https://github.com/wooorm/remark) 提高精准度
151
152使用 [`translation.js`](https://github.com/Selection-Translator/translation.js) 完成 与翻译网站的交互
153
154还有个 [异步 Promise 递归的 例子](https://github.com/chinanf-boy/translate-mds/blob/master/src/setObjectKey.js#L78)