Skip to content

Commit

Permalink
Auto-translate README
Browse files Browse the repository at this point in the history
  • Loading branch information
Continuous Integration committed Sep 25, 2023
1 parent 4716484 commit 4abc5d9
Show file tree
Hide file tree
Showing 4 changed files with 365 additions and 85 deletions.
99 changes: 99 additions & 0 deletions README.Arabic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# action-translate-readme

* [الإنجليزية](README.md)
* [قراءة الإصدار التقليدي ل README.md](README.zh-TW.md)
* [الصينية المبسطة](README.zh-CN.md)
* [فرنسي](README.French.md)
* [عربى](README.Arabic.md)


# المقدمة

* نعلم جميعًا أن كتابة مستند README تستغرق وقتًا طويلاً ، ولكن الآن هناك حل يمكن أن يوفر لك النصف من وقتك. هذا هو `action-translate-readme` الخاص بنا

* ترجمة إصدارات README المختلفة بواسطة `gpt3.5`

* عن طريق ** Github Actions (CI / CD) التحميل التلقائي للكتابة(commit، push)** للملفات المترجمة

* على سبيل المثال: ** كتابة **أو** تعديل **إصدار README الإنجليزي، توليد إصدار README الصيني التقليدي و الصيني المبسط و الفرنسي... إلخ

ملاحظة: يتم تحقيق المترجم في الإصدار v1 عن طريق حزمة جانبية من `Linux` ؛ ويتم تحقيق الإصدار v2 عن طريق استخدام برنامج [`g4f`](https://github.com/xtekky/gpt4free) لاستخدام ترخيص openai بشكل مجاني.


# كيفية الاستخدام؟

1. انقر فوق رمز النجمة لإضافة هذا المشروع إلى مستودع GitHub الخاص بك.

2. تعيين `Github Token` الخاص بك:

* [قم بإنشاء **`Github Secret Token`** جديد](https://github.com/settings/tokens/new)
* إعداد
* تمكين المطور
* بيانات اعتماد الوصول الشخصية - `الرموز الكلاسيكية`
* إنشاء رمز جديد
* اختر النطاق: `repo` و `workflow`
* **حافظ** على الرمز السري الخاص بك (لا تفقده ، ستحتاج إليه في المستقبل)

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/b7487b49-817c-4925-b94a-bdb7b025a0c2" width=" 60%" />

* أنشئ مفتاح سرّي جديد للـ **`repository secret`**
* في مستودعك - الإعدادات
* `Securits and variables`
* `Actions`
* `New repository secret`
* اضغط على `token` ثم قم بتسميته (مثل: `Action_Bot`)

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/27dc7bcd-633f-431e-98e8-387b97ecd47c" width=" 60%" />

3. في الدليل `.github/workflows/your_action.yml`.، قم بإنشاء مثال عملك ، يمكنك نسخه مباشرة:

```
# .github/workflows/translate.yml
name: Translate Readme
on:
push:
branches: ['**']
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 3
- name: Auto Translate
uses: Lin-jun-xiang/action-translate-readme@v2 # Based on the tag
with:
token: ${{ secrets.Action_Bot }} # Based on step2 name
g4f_provider: g4f.Provider.DeepAi # You can change this provider
langs: "en,zh-TW,zh-CN,French,Arabic" # You can define any langs
```

هناك ثلاثة معلمات في `.yml` يجب مراعاتها بشكل خاص:

* `token`: الرمز السري الذي تم إنشاؤه بموجب الخطوة 2 في المستودع
* `g4f_provider`: مزود gpt ، يرجى الرجوع إلى [هذا الرابط](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4) للحصول على مزيد من المعلومات
* `langs`: أي لغات تريد إنشاء إصدارات لها ، يرجى تحديدها بفصلها بـ `,` ، مثلاً:
* `"en"`: الإنجليزية فقط
* `"en,zh-TW"`: الإنجليزية، الصينية التقليدية
* `"French,Arabic"`: الفرنسية، العربية

4. يمكنك الآن تحديث `README.md` ، وسيتم إنشاء إصدار مترجم تلقائيًا!

---

# مثال توضيحي

![](./img/auto-translation.gif)

---

# نتائج الوثيقة الاختبارية

* راجع [الوثيقة التجريبية](https://github.com/Lin-jun-xiang/vscode-extensions-best/tree/main)
* استخدم أداتنا لتحديث الوثيقة الاختبارية

<a href="#top">عودة إلى أعلى الصفحة</a>
99 changes: 99 additions & 0 deletions README.French.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# action-translate-readme

* [English](README.md)
* [繁體中文版README.md](README.zh-TW.md)
* [简体中文](README.zh-CN.md)
* [Française](README.French.md)
* [عربى](README.Arabic.md)

# Introduction

* Nous savons tous que la rédaction de README est très chronophage, mais il y a maintenant une solution pour vous permettre de gagner la moitié du temps. C'est notre "action-translate-readme".

* Traduction des différentes versions des README dans différentes langues grâce à "gpt3.5"

* Soumission automatique(commit, push) des documents traduits grâce à la fonction intégrée des actions Github (CI/CD)

* Par exemple : "Le fait de rédiger" ou de "modifier" la version anglaise de README va automatiquement générer des versions de README en chinois traditionnel, en chinois simplifié, en français, etc.

Note : Pour la version 1 du traducteur, un système tiers sur "Linux" a été utilisé tandis que pour la version 2, une API openai gratuite appelée "g4f" a été utilisée pour la traduction.

# Comment utiliser ?

1. Appuyez sur l'icône :star: pour ajouter ce projet à votre entrepôt

2. Configurez votre "Github Token" :

* [Créer un nouveau "**Github Secret Token**"](https://github.com/settings/tokens/new)
* Réglage
* Configuration du développeur
* Jeton d'accès personnel - "Tokens(classic)"
* Générer un nouveau jeton
* Choisissez le scope : "repo" et "workflow"
* **Conservez** votre secret token (ne le perdez pas, vous en aurez besoin plus tard)

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/b7487b49-817c-4925-b94a-bdb7b025a0c2" width=" 60%" />

* Créer un nouveau "**repository secret**" :
* Dans votre entrepôt - "settings"
* Sécurité et variables
* Actions
* Nouveau secret de l'entrepôt
* Appuyez sur "token" pour ajouter des tags et un nom ("Action_Bot" par exemple).

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/27dc7bcd-633f-431e-98e8-387b97ecd47c" width=" 60%" />

3. Dans le dossier ".github/workflows/your_action.yml", créez votre exemple d'action. Vous pouvez directement copier ce code :

```
# .github/workflows/translate.yml
name: Translate Readme
on:
push:
branches: ['**']
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 3
- name: Auto Translate
uses: Lin-jun-xiang/action-translate-readme@v2 # Based on the tag
with:
token: ${{ secrets.Action_Bot }} # Based on step2 name
g4f_provider: g4f.Provider.DeepAi # You can change this provider
langs: "en,zh-TW,zh-CN,French,Arabic" # You can define any langs
```

Il y a trois paramètres à prendre en compte dans ".yml" :

* "token" : basé sur le nom de l'étape 2.

* "g4f_provider" : pour le fournisseur GPT, veuillez vous référer au [lien](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4)

* "langs" : définir les langues que vous souhaitez générer, elles doivent être séparées par des virgules. Par exemple :
* "en": uniquement pour l'anglais
* "en,zh-TW": pour l'anglais et le chinois (traditionnel)
* "French,Arabic": pour le français et l'arabe

4. Vous pouvez maintenant mettre à jour le "README.md". Cela générera automatiquement une version traduite !

---

# Demo

![](./img/auto-translation.gif)

---

# Results of Test Document

* Regardez le [document de test] (https://github.com/Lin-jun-xiang/vscode-extensions-best/tree/main)
* Mettez à jour notre document de test avec notre outil

<a href="#top">Retour en haut de la page</a>
150 changes: 65 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,87 @@
# action-translate-readme

[English Version](README.md) | [Chinese Version README.md](README.zh-TW.md)
* [English](README.md)
* [Traditional Chinese README.md](README.zh-TW.md)
* [Simplified Chinese README.md](README.zh-CN.md)
* [French](README.French.md)
* [Arabic](README.Arabic.md)

# What's changed for action-translate-readme?

With the emergence of ChatGPT, the author thought that the translation task of this project could be handed over to GPT for implementation. Through the open source project [`gpt4free`](https://github.com/xtekky/gpt4free), we can realize the free GPT API and hope to enhance the translation ability of this project!
# Introduction

* Version 1 translation method: implemented through third-party Linux packages (`translation.sh`)
* Translation effect: poor, similar to Google Translate
* Translation speed: slow
* Stability: high, can ensure correct translation every time
* We all know that writing README documentation can be time-consuming, but now there is a solution that can save you half of your time. This is our `action-translate-readme`.

* Version 2 translation method: using GPT for translation task (`translation.py`)
* Translation effect: good
* Translation speed: fast or slow
* Stability: low
* Translate different language versions of README via `gpt3.5`.

Since `gpt4free` uses reverse engineering to realize free API calls, the calling process may encounter abnormal problems. The author added `retry` technology (they will be executed again when abnormal events occur) when calling the API function to avoid translation failure. As a result, the translation speed will increase with the number of retries.
* Automatically submit (commit, push) the translated files through **Github Actions (CI/CD)**.

> Please **note** that there are [different providers](https://github.com/xtekky/gpt4free#models) in `gpt4free`, which are the sources that provide API calls. If you cannot use the automatic translation tool of this project normally, the problem usually comes from the provider currently used and is **inactive**. Therefore, you can set the [parameter](.github\workflows\translate-readme.yml) yourself in your `translate-readme.yml` file (default is `g4f.Provider.DeepAi`).
>
> In addition, since it is a **generative AI** technology, it cannot guarantee that each translation is correct. If the translation effect is not good, you can repeat it several times.
* For example: When you **write** or **modify** the English version of the README, the translated versions, such as Traditional Chinese, Simplified Chinese, French, etc., are automatically generated.

Note: The translator of v1 version is implemented through third-party packages on `Linux`; v2 version is implemented through free openai api called [`g4f`](https://github.com/xtekky/gpt4free)

# Introduction

* We all know that writing documents takes a lot of time, but now there is a solution that can save you half of the time. This is our `action-translate-readme`.
# How to use?

* With this tool, you can automatically translate the `README.md` file, not only can translate, but also translates various elements such as **inline code, emojis, code blocks, HTML tags and links.**
1. Click :star: icon to add this project to your Github repository.

* Its operating principle is to achieve automation through `Github Actions`. Just push the updated README file, and the translated README (zh or en) file can be automatically updated.
2. Set up your `Github Token`:

* Continuous integration (CI)
* [Create a new **`Github Secret Token`**](https://github.com/settings/tokens/new)
* Settings
* Developer settings
* Personal access tokens - `Tokens(classic)`
* Generate a new token
* Choose scopes: `repo` and `workflow`
* **Keep** your secret token (do not lose it, you need to paste it later)

* **Automatically translate the language of README through Github Action**
<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/b7487b49-817c-4925-b94a-bdb7b025a0c2" width=" 60%" />

* Update `README.md` and push it. This action will automatically update `README.zh-TW.md`
(Updating `README.zh-TW.md` will automatically update `README.md`)
* Create a new **`repository secret`**
* In your repository - `settings`
* `Security and variables`
* `Actions`
* `New repository secret`
* Fill in the tag with `token` and name it (e.g. `Action_Bot`)

* Half of the time spent on writing documents is saved.
<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/27dc7bcd-633f-431e-98e8-387b97ecd47c" width=" 60%" />

# Features
3. Create your action example in the directory `.github/workflows/your_action.yml`. You can just copy the following code:

* Untranslated:
* Inline code (`inline_code`)
* Used for emoji
* Code block
* HTML tags
* Link
```
# .github/workflows/translate.yml
name: Translate Readme
# How to use?
on:
push:
branches: ['**']
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 3
- name: Auto Translate
uses: Lin-jun-xiang/action-translate-readme@v2 # Based on the tag
with:
token: ${{ secrets.Action_Bot }} # Based on step2 name
g4f_provider: g4f.Provider.DeepAi # You can change this provider
langs: "en,zh-TW,zh-CN,French,Arabic" # You can define any langs
```

There are three parameters to pay special attention to in `.yml`:

* `token`: The token created in the repo based on step 2.
* `g4f_provider`: The provider of gpt, please refer to the [link](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4) for more information.
* `langs`: The language versions to be generated. Be sure to separate different languages with `,`. For example:
* `"en"`: Translate only the English version.
* `"en,zh-TW"`: Translate English and Traditional Chinese.
* `"French,Arabic"`: Translate French and Arabic.

1. Click on the :star: icon to add this item to your Github repository.

2. Set your `Github Token`:
* [Create a new **`Github Secret Token`**](https://github.com/settings/tokens/new)
* Set
* Developer settings
* Personal access tokens - `Tokens(classic)`
* Generate new token
* Choose scope: `repo` and `workflow`
* **Keep** your secret token (do not throw it away, it needs to be pasted later)

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/b7487b49-817c-4925-b94a-bdb7b025a0c2" width=" 60%" />
* Create a new **`repository secret`**
* In your repository - `settings`
* `Securits and variables`
* `Actions`
* `New repository secret`
* Fill in the tag and name it (eg: `Action_Bot`) in `token`

<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/27dc7bcd-633f-431e-98e8-387b97ecd47c" width=" 60%" />
3. Create the README language you want: `README.md`, `READM.zh-TW.md`,...

4. Create your action example in directory `.github/workflows/your_action.yml`.

```
# .github/workflows/translate.yml
name: Translate Readme
on:
push:
branches: ['**']
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 3
- name: Auto Translate
uses: Lin-jun-xiang/action-translate-readme@v2 # Based on the tag
with:
token: ${{ secrets.Action_Bot }} # Based on step2 name
g4f_provider: g4f.Provider.DeepAi # You can change this provider
```

5. Now you can update the `README.md`, and a translated version will be generated automatically!
4. Now you can update `README.md`, and it will automatically generate a translated version!

---

Expand All @@ -113,7 +93,7 @@ With the emergence of ChatGPT, the author thought that the translation task of t

# Results of Test Document

* View [test document](https://github.com/Lin-jun-xiang/vscode-extensions-best/tree/main)
* Update the test document using our tool
* Check out the [test document](https://github.com/Lin-jun-xiang/vscode-extensions-best/tree/main).
* Use our tool to update the test document.

<a href="#top">Back to top</a>
Loading

0 comments on commit 4abc5d9

Please sign in to comment.