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 Dec 5, 2023
1 parent 9e8ae9e commit 9779814
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 274 deletions.
96 changes: 9 additions & 87 deletions README.Arabic.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,104 +11,26 @@
* [عربى](README.Arabic.md)


# المقدمة
# Introduction

> [!NOTE]
> إن مترجم الإصدار `v1` تم تنفيذه باستخدام حزمة الطرف الثالث `Linux`؛ بينما يتم تنفيذ الإصدار `v2` باستخدام [`g4f`](https://github.com/xtekky/gpt4free) لاستدعاء واجهة برمجة تطبيقات openai مجانًا للترجمة.
> `v1`版本的翻譯器是透過 `Linux` 第三方套件實現;`v2`版本是透過 [`g4f`](https://github.com/xtekky/gpt4free) 免費調用 openai api 實現翻譯

* نعلم جميعًا أن كتابة وثيقة README تستغرق وقتًا طويلاً ، ولكن الآن هناك حلاً يمكنك من خلاله توفير نصف الوقت. هذا هو `action-translate-readme` لدينا.
* 我們都知道寫README文檔很費時間,但是現在有一個解決方案可以讓你節省一半的時間. 這就是我們的`action-translate-readme`

* قم بترجمة إصدارات README المختلفة بواسطة `gpt3.5`.
* 通過 `gpt3.5` 翻譯不同語言版本的 README

* تقديم **Github Actions(CI/CD) للترجمة التلقائية (commit، push)** للملفات المترجمة.
* 透過 **Github Actions(CI/CD) 自動提交(commitpush)** 翻譯後的檔案

* على سبيل المثال: **كتابة** أو **تعديل** إصدار README باللغة الإنجليزية ، ستتم إنشاء إصدارات README باللغة التايوانية التقليدية واللغة الصينية المبسطة واللغة الفرنسية وما إلى ذلك.
* 例如: **撰寫****修改**英文版README,自動生成繁體中文、簡體中文、法文...等版本 README


# كيفية الاستخدام؟
# How to use ?


> [!IMPORTANT]
> نظرًا لأن `gpt3.5` هو نموذج AI القائم على الإنتاج ، فإنه يحتمل أن تكون هناك مشاكل في كل نتيجة للترجمة ، ويُنصح باستخدام الفروع للاختبار ومحاولة عدة مرات.
> 由於 `gpt3.5` 屬於生成式 AI 模型,因此每次翻譯結果都有機率出現問題,建議使用分支測試,並多嘗試幾次。
> [!WARNING]
> إذا واجهت الخطأ التالي: `Error: Input required and not supplied: token`، يُرجى التأكد من إنشاء `Token` وفقًا للخطوة الثانية ، أو التحقق مما إذا كان الـ `Token` قد انتهت صلاحيته!
1. انقر على رمز النجمة :star: لإضافة هذا المشروع إلى مستودع Github الخاص بك.

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

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

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

* أنشئ **`repository secret`** جديدًا
* في مستودعك - `settings`
* `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>
--------------------------------
> 如果你遇到如下錯誤: `Error: Input required and not supplied: token`,請根據步驟二確定已建立 `Token`,或者 `Token` 是否已
70 changes: 37 additions & 33 deletions README.French.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
```markdown
# action-translate-readme

<p align="center">
<img src="img/2023-11-13-16-50-04.png" width="60%"/>
</p>

* [English](README.md)
* [Anglais](README.md)
* [繁體中文版README.md](README.zh-TW.md)
* [简体中文](README.zh-CN.md)
* [Française](README.French.md)
Expand All @@ -14,53 +15,54 @@
# Introduction

> [!NOTE]
> La version `v1` du traducteur est implémentée à l'aide d'un package tiers `Linux`; la version `v2` est mise en œuvre en appelant gratuitement l'API openai à l'aide de [`g4f`](https://github.com/xtekky/gpt4free).
> Le traducteur de la version `v1` est mis en œuvre à l'aide d'un package tiers sous `Linux`; la version `v2` est mise en œuvre via [`g4f`](https://github.com/xtekky/gpt4free) en appelant gratuitement l'API openai pour la traduction.


* Nous savons tous que rédiger une documentation README prend beaucoup de temps, mais il existe maintenant une solution qui vous permet d'économiser la moitié de votre temps. C'est notre `action-translate-readme`.
* Nous savons tous que la rédaction de la documentation README prend beaucoup de temps, mais il existe maintenant une solution qui peut vous faire gagner la moitié du temps. C'est notre `action-translate-readme`

* Traduisez différentes versions de README dans différentes langues en utilisant `gpt3.5`.
* Traduisez différentes versions linguistiques de README avec `gpt3.5`

* Soumettez automatiquement (commit, push) les fichiers traduits à l'aide de **Github Actions (CI/CD)**.
* Par le biais de **Github Actions(CI/CD)**, soumettez automatiquement les fichiers traduits (commit, push) après la traduction

* Par exemple: **Écrivez** ou **modifiez** la version anglaise de README, et les versions en chinois traditionnel, en chinois simplifié, en français, etc., seront générées automatiquement.
* Par exemple: **Écrivez** ou **modifiez** la version anglaise de README, générant automatiquement les versions en chinois traditionnel, chinois simplifié, français, etc.


# Comment utiliser ?


> [!IMPORTANT]
> Comme `gpt3.5` est un modèle d'IA génératif, il y a une probabilité que chaque résultat de traduction présente des problèmes. Il est recommandé de tester sur une branche et d'essayer plusieurs fois.
> Étant donné que `gpt3.5` est un modèle d'IA génératif, il y a toujours une probabilité d'erreurs dans les résultats de la traduction. Il est recommandé de faire des tests sur une branche et d'essayer plusieurs fois.

> [!WARNING]
> Si vous rencontrez l'erreur suivante : `Error: Input required and not supplied: token`, veuillez suivre l'étape 2 pour vérifier si vous avez créé le `Token` ou si le `Token` est expiré !
> Si vous rencontrez l'erreur suivante: `Error: Input required and not supplied: token`, veuillez vérifier à l'étape 2 si vous avez créé un `Token` et si le `Token` a expiré !

1. Cliquez sur l'icône :star: pour ajouter ce projet à votre dépôt Github.

2. Configurez votre `Github Token` :

* [Créez un nouveau **`Github Secret Token`**](https://github.com/settings/tokens/new)
* Réglages
* Réglages développeur
* Configuration
* Paramètres du développeur
* Jetons d'accès personnels - `Tokens(classic)`
* Générer un nouveau jeton
* Choisissez la **durée de vie** du jeton - il est recommandé d'utiliser **illimité**
* Choisissez les autorisations : `repo` et `workflow`
* **Conservez** votre secret token (ne le perdez pas, vous en aurez besoin plus tard)
* Choisissez la **durée de vie** du jeton - il est recommandé d'utiliser **Indéfini**
* Choisissez la portée : `repo` et `workflow`
* **Conservez** votre jeton secret (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%" />
<img src="https://github.com/Lin-jun-xiang/action-translate-readme/assets/63782903/b7487b49-817c-4925-b94a-bdb7b025a0c2" width="60%" />

* Créez un nouveau **`repository secret`**
* Dans votre dépôt - Paramètres
* Sécurité et variables
* Actions
* Nouveau secret de dépôt
* Étiquetez et nommez le secret (par ex : `Action_Bot`)
* Dans votre dépôt - `Paramètres`
* `Sécurité et variables`
* `Actions`
* `Nouveau secret de dépôt`
* Appuyez sur `token`, remplissez l'étiquette et donnez un nom (par exemple: `Action_Bot`)

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

3. Créez votre exemple d'action dans le répertoire `.github/workflows/your_action.yml`. Vous pouvez simplement copier le contenu suivant :

```
```yaml
# .github/workflows/translate.yml
name: Translate Readme

Expand All @@ -83,18 +85,20 @@
token: ${{ secrets.Action_Bot }} # Basé sur le nom de l'étape 2
g4f_provider: g4f.Provider.DeepAi # Vous pouvez changer ce fournisseur
langs: "en,zh-TW,zh-CN,French,Arabic" # Vous pouvez définir n'importe quelles langues
# openai_api_key: ${{ secrets.OPENAI_API_KEY }} # Si vous passez la clé api openai, elle utilisera gpt d'openai au lieu de gpt4free
```

Il y a trois paramètres dans le `.yml` à noter :

* `token` : le token créé dans l'étape 2 dans le repo
* `g4f_provider` : le fournisseur de gpt, pour en savoir plus, veuillez consulter le [lien](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4)
* `langs` : les versions linguistiques que vous souhaitez générer, veillez à séparer les différentes langues par des virgules, par exemple :
* `"en"` : traduire uniquement la version anglaise
* `"en,zh-TW"` : traduire l'anglais et le chinois traditionnel
* `"French,Arabic"` : traduire le français et l'arabe
> [!NOTE]
> Il y a quelques paramètres dans le `.yml` à noter :
> * `token` **(obligatoire)** : Selon l'étape 2, le token créé dans le repos
> * `g4f_provider` **(optionnel)** : Le fournisseur de gpt, pour plus d'informations, veuillez consulter le [lien](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4)
> * `langs` **(obligatoire)** : Les versions linguistiques que vous souhaitez générer, assurez-vous de séparer les langues par des virgules, par exemple :
> * `"en"`: Traduire uniquement la version anglaise
> * `"en,zh-TW"`: Traduire l'anglais et le chinois traditionnel
> * `"French,Arabic"`: Traduire le français et l'arabe
> * `openai_api_key` **(optionnel)** : Si vous souhaitez utiliser gpt de l'api openai, vous pouvez créer une clé api openai de la même manière qu'à l'étape 2, créez une clé api openai et **n'ajoutez pas directement la clé au fichier yml, pour éviter toute fuite d'informations !**

4. Maintenant, vous pouvez mettre à jour `README.md`, et une version traduite sera générée automatiquement !
4. Vous pouvez maintenant mettre à jour `README.md`, il générera automatiquement une version traduite !

---

Expand All @@ -106,8 +110,8 @@

# Résultats du document de test

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

<a href="#top">Retour en haut</a>
--------------------------------
```
88 changes: 13 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

* [English](README.md)
* [Traditional Chinese Version README.md](README.zh-TW.md)
* [Traditional Chinese version README.md](README.zh-TW.md)
* [Simplified Chinese](README.zh-CN.md)
* [French](README.French.md)
* [Arabic](README.Arabic.md)
Expand All @@ -14,100 +14,38 @@
# Introduction

> [!NOTE]
> The translator of version `v1` is implemented through a third-party package on `Linux`; version `v2` is implemented by calling the OpenAI API for free through [`g4f`](https://github.com/xtekky/gpt4free).
> The translator of version `v1` is implemented through third-party packages on `Linux`; `v2` version is achieved through calling openai api for translation using [`g4f`](https://github.com/xtekky/gpt4free) for free.

* We all know that writing README documentation takes a lot of time, but now there is a solution that can save you half the time. This is our `action-translate-readme`.
* We all know that writing README documentation takes a lot of time, but now there is a solution that can save you half the time. This is our `action-translate-readme`

* Translate different language versions of README using `gpt3.5`.
* Translate different language versions of README through `gpt3.5`

* Automatically commit (commit, push) the translated files through **Github Actions (CI/CD)**.
* Automatically commit (commit, push) translated files through **Github Actions (CI/CD)**

* For example: **Write** or **modify** the English version of README, and automatically generate versions of README in Traditional Chinese, Simplified Chinese, French, etc.
* For example: **write** or **modify** the English version README, automatically generate traditional Chinese, simplified Chinese, French... and other versions of README


# How to use?
# How to use ?


> [!IMPORTANT]
> Since `gpt3.5` is a generative AI model, there is a chance of problems with the translation results each time. It is recommended to use branch testing and try several times.
> Since `gpt3.5` belongs to a generative AI model, there is a probability of problems in the translation results each time. It is recommended to use branch testing and try several times.
> [!WARNING]
> If you encounter the following error: `Error: Input required and not supplied: token`, please follow step two to ensure that the `Token` has been created or whether the `Token` has expired!
> If you encounter the following error: `Error: Input required and not supplied: token`, please make sure to create a `Token` according to step two, or check if the `Token` has expired!
1. Click on the :star: icon to add this project to your Github repository.
1. Click the :star: icon to add this item to your Github repository.

2. Set up your `Github Token`:
2. Set your `Github Token`:

* [Create a new **`Github Secret Token`**](https://github.com/settings/tokens/new)
* Setting
* Settings
* Developer settings
* Personal access tokens - `Tokens (classic)`
* Generate new token
* Choose token **lifespan** - it is recommended to use **unlimited**
* Choose scopes: `repo` and `workflow`
* **Keep** your secret token (do not lose it, you will need to paste it 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 label with `token` and name it (eg: `Action_Bot`)

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

3. Create an example of your action in the directory `.github/workflows/your_action.yml`. You can directly copy the following:

```
# .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
```

There are three parameters in `.yml` that need special attention:

* `token`: The token created in the repos based on step 2.
* `g4f_provider`: The provider of gpt, for more information, please refer to the [link](https://github.com/xtekky/gpt4free/tree/main#gpt-35--gpt-4)
* `langs`: The language versions you want to generate, 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

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

---

# Demo

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

---

# Results of Test Document

* View 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>
<img src="https://github.com/Lin-j
Loading

0 comments on commit 9779814

Please sign in to comment.