Skip to content

Commit 767ded0

Browse files
committed
a-t aya-8b
1 parent f737390 commit 767ded0

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

.github/workflows/translate.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: AI Readme Translator (German)
1+
name: AI Readme Translator (Multilingual)
22

33
on:
44
workflow_dispatch:
@@ -11,7 +11,11 @@ permissions:
1111

1212
jobs:
1313
translate:
14+
name: Translate to ${{ matrix.lang }}
1415
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
lang: [de, fr, es, ja, zh] # German, French, Spanish, Japanese, Chinese
1519
steps:
1620
- name: Checkout Code
1721
uses: actions/checkout@v4
@@ -40,11 +44,31 @@ jobs:
4044
wget -O models/aya-expanse-8b-q4_k_s.gguf https://huggingface.co/matrixportalx/aya-expanse-8b-Q4_K_S-GGUF/resolve/main/aya-expanse-8b-q4_k_s.gguf
4145
4246
- name: Run Translation Script
43-
run: python scripts/translate.py
47+
run: python scripts/translate.py --lang ${{ matrix.lang }}
4448

45-
- name: Commit and Push
49+
- name: Upload Translation Artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: readme-${{ matrix.lang }}
53+
path: locales/README.${{ matrix.lang }}.md
54+
55+
commit-translations:
56+
needs: translate
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout Code
60+
uses: actions/checkout@v4
61+
62+
- name: Download All Translations
63+
uses: actions/download-artifact@v4
64+
with:
65+
pattern: readme-*
66+
path: locales
67+
merge-multiple: true
68+
69+
- name: Commit and Push Changes
4670
uses: stefanzweifel/git-auto-commit-action@v5
4771
with:
48-
commit_message: "docs: update german translation"
49-
file_pattern: 'locales/translated_readme.md'
72+
commit_message: "docs: update multilingual translations"
73+
file_pattern: 'locales/*.md'
5074
push_options: '--force-with-lease'

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<div align="center">
2+
<a href="README.md">🇺🇸 English</a> |
3+
<a href="locales/README.de.md">🇩🇪 Deutsch</a> |
4+
<a href="locales/README.fr.md">🇫🇷 Français</a> |
5+
<a href="locales/README.es.md">🇪🇸 Español</a> |
6+
<a href="locales/README.ja.md">🇯🇵 日本語</a> |
7+
<a href="locales/README.zh.md">🇨🇳 中文</a>
8+
</div>
9+
110
<div style="text-align:center; margin:18px 0;">
211
<img src="monitor/api/static/logo.png" alt="MyGPU logo"/>
312
</div>

scripts/translate.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import os
22
import re
3+
import argparse
34
from llama_cpp import Llama
45

6+
# Map language codes to full English names for the system prompt
7+
LANG_MAP = {
8+
"de": "German",
9+
"fr": "French",
10+
"es": "Spanish",
11+
"ja": "Japanese",
12+
"zh": "Chinese (Simplified)",
13+
"ru": "Russian"
14+
}
15+
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument("--lang", type=str, required=True, help="Target language code (e.g., de, fr)")
18+
args = parser.parse_args()
19+
20+
target_lang_name = LANG_MAP.get(args.lang, "English")
21+
522
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
623
README_PATH = os.path.join(BASE_DIR, "README.md")
724
OUTPUT_DIR = os.path.join(BASE_DIR, "locales")
8-
OUTPUT_PATH = os.path.join(OUTPUT_DIR, "translated_readme.md")
25+
OUTPUT_PATH = os.path.join(OUTPUT_DIR, f"README.{args.lang}.md")
926
MODEL_PATH = os.path.join(BASE_DIR, "models", "aya-expanse-8b-q4_k_s.gguf")
1027

1128
# Ensure output directory exists
@@ -21,10 +38,10 @@
2138
# Aya Expanse uses a specific header format for system/user/chatbot turns
2239
prompt = f"""<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>
2340
You are a professional technical translator.
24-
Perform a strict technical translation of the provided README into professional developer-level German.
41+
Perform a strict technical translation of the provided README into professional developer-level {target_lang_name}.
2542
Maintain a formal tone and preserve technical terminology (e.g., GPU, CLI, vCPU).
2643
Keep all Markdown/HTML syntax exactly as is.
27-
ONLY output the translated German text. No talk, just translation.
44+
ONLY output the translated {target_lang_name} text. No talk, just translation.
2845
Do not add new information, do not summarize, and do not include any conversational filler or "thinking" process.<|END_OF_TURN_TOKEN|>
2946
<|START_OF_TURN_TOKEN|><|USER_TOKEN|>
3047
{text_to_translate}<|END_OF_TURN_TOKEN|>
@@ -66,4 +83,4 @@
6683
with open(OUTPUT_PATH, "w", encoding="utf-8") as f:
6784
f.write(translated_content)
6885

69-
print("Translation complete.")
86+
print(f"Translation to {target_lang_name} complete: {OUTPUT_PATH}")

0 commit comments

Comments
 (0)