11import os
22import re
3+ import argparse
34from 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+
522BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
623README_PATH = os .path .join (BASE_DIR , "README.md" )
724OUTPUT_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" )
926MODEL_PATH = os .path .join (BASE_DIR , "models" , "aya-expanse-8b-q4_k_s.gguf" )
1027
1128# Ensure output directory exists
2138# Aya Expanse uses a specific header format for system/user/chatbot turns
2239prompt = f"""<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>
2340You 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 } .
2542Maintain a formal tone and preserve technical terminology (e.g., GPU, CLI, vCPU).
2643Keep 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.
2845Do 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|>
6683with 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