better Readme

This commit is contained in:
Pierre
2023-12-07 17:40:43 +01:00
parent 26e5287895
commit 681489c39e
2 changed files with 58 additions and 19 deletions
+56 -16
View File
@@ -1,57 +1,97 @@
# Automatic doc translation with OpenAI
# OpenAI Automatic Documentation Translation
This tool leverages the capabilities of OPEN AI GPT 3.5 / 4 to automatically translate documentation files (i.e., .md/.mdx files) within a GitHub repository.
[Simplified Chinese](./README_zh-Hans.md) | [Spanish](./README_es.md) | [French](./README_fr.md) | [Russian](./README_ru.md) | [German](./README_de.md) | [Japanese](./README_ja.md) | [Korean](./README_ko.md) | [Portuguese](./README_pt.md) | [Italian](./README_it.md) | [Arabic](./README_ar.md) | [Turkish](./README_tr.md) | [Polish](./README_pl.md) | [Dutch](./README_nl.md) | [Vietnamese](./README_vi.md) | [Thai](./README_th.md) | [Persian](./README_fa.md) | [Romanian](./README_ro.md) | [Swedish](./README_sv.md) | [Hungarian](./README_hu.md) | [Czech](./README_cs.md) | [Greek](./README_el.md) | [Danish](./README_da.md) | [Finnish](./README_fi.md) | [Hebrew](./README_he.md) | [Norwegian](./README_no.md) | [Hindi](./README_hi.md) | [Traditional Chinese](./README_zh_tw.md) | [Indonesian](./README_in.md) | [Slovak](./README_sl.md) | [Serbian](./README_se.md) | [Slovenian](./README_sk.md) | [Ukrainian](./README_uk.md) | [Bulgarian](./README_bg.md) | [Croatian](./README_hr.md) | [Lithuanian](./README_lt.md) | [Latvian](./README_lv.md) | [Estonian](./README_et.md) | [Catalan](./README_cat.md)
*** Disclaimer: This tool is currently under development ***
A tool that automatically transalte the doc (every .md files) in a github repo using OPEN AI GPT 3.5
## Installation
*** Disclaimer: This tool is still experiemental ***
The tool can be installed via NPM:
## Usage
First install
```
npm install -g autotranslatedoc
```
Then make sure you set up the following environment variables: ```GITHUB_PERSONAL_ACCESS_TOKEN``` and ```OPENAI_API_KEY```. Alternatively you can pass this token in parameter
Ensure to set up the environment variables: `GITHUB_PERSONAL_ACCESS_TOKEN` and `OPENAI_API_KEY`. Alternatively, these tokens can be passed as parameters. Refer to the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) for obtaining a `GITHUB_PERSONAL_ACCESS_TOKEN`.
To see helppage
## Usage
### Help Page
Access the help page with the following command:
```
autotranslatedoc -h
```
Then translate the doc of a target repo in french and spanish
### Translating Documentation
To translate the documentation of a target repository into French and Spanish, use:
```
autotranslatedoc translate run-llama llama_index -l fr,es
```
This will create a llama_index.json file it the run-lama directory of the specified output directory (default=./save)
This command creates a `llama_index.json` file in the `run-lama` directory of the specified output directory (default is `./save`).
```
ls ./save
run-llama
llama_index.json
```
The save file contains all translations and can be used to generate the documentation in a target format (currently only .md).
This save file contain all the translation and can be used to generate the do to a target format (currently only .md)
To build the translated documentation, use:
```
autotranslatedoc build run-llama llama_index -l fr,es
```
This will generate a fr and es repository in the buildPath (default ./build) that will contain the translated doc files
This command generates `fr` and `es` directories in the `buildPath` (default is `./build`) containing the translated documentation files.
To update the translated documentation based on changes in the original files, use:
```
autotranslatedoc update run-llama llama_index -l fr,es
```
This will look at pre-existing translation in the existing doc save file and will perform a differential translation of every file that have been updated.
To review the documentation via a server (experimental feature), use:
```
autotranslatedoc serve run-llama llama_index
```
Will launch a server allowing the easy review of the doc on port 3000 or env.PORT. EXPERIMENTAL
### Translating Docusaurus Documentation
For translating documentation hosted in Docusaurus, use:
```
autotranslatedoc translate run-llama LlamaIndexTS --docPath /apps/docs/docs -l fr,es -m docusaurus
autotranslatedoc build run-llama LlamaIndexTS --docPath /apps/docs/docs -l fr,es -m docusaurus
```
### Translating README.md Only
To translate only the README file, use the `readme` mode:
```
autotranslatedoc translate run-llama LlamaIndexTS -l fr,es -m readme
autotranslatedoc build run-llama LlamaIndexTS -l fr,es -m readme
```
### Translating to All Supported Languages
To translate to all supported languages, use the `-l all` option:
```
autotranslatedoc translate run-llama LlamaIndexTS -l all -m readme
autotranslatedoc build run-llama LlamaIndexTS -l all -m readme
```
## Known Issues
Currently, translation with `-all` is only supported from English to all other languages.
+2 -3
View File
@@ -153,12 +153,11 @@ async function buildOutputMd(files, languageCode, targetDir, prefixToRemove, tar
}
function getLanguageMenu(languageCode, language) {
let md = "\n\n[English](./README.md)";
let md = "\n\n[EN](./README.md)";
for (let lang of language) {
if (lang != languageCode) {
md += `| [${supportedLanguages[lang]}](./README_${lang}.md) `;
md += `| [${lang}](/i18n/README_${lang}.md) `;
}
}
return md;