aoeu
This commit is contained in:
@@ -37,11 +37,16 @@ async def mutate_chinese_titles(data: Dict[str, Any]) -> None:
|
|||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if key in title_keys and isinstance(value, str) and contains_chinese(value):
|
if key in title_keys and isinstance(value, str) and contains_chinese(value):
|
||||||
try:
|
try:
|
||||||
|
chinese_value = value
|
||||||
|
if chinese_value.contains("--"):
|
||||||
|
idx = value.index("--")
|
||||||
|
chinese_value, _ = value[:idx]
|
||||||
|
|
||||||
# Translate Chinese text to English
|
# Translate Chinese text to English
|
||||||
translation = await translator.translate(value, dest='en')
|
translation = await translator.translate(chinese_value, dest='en')
|
||||||
data[key] = data[key] + "--" + translation.text
|
data[key] = chinese_value + "--" + translation.text
|
||||||
|
|
||||||
console.print(f"[dim]Translated '{value}' → '{translation.text}'[/dim]")
|
console.print(f"[dim]Translated '{chinese_value}' → '{translation.text}'[/dim]")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.print(f"[yellow]Warning: Failed to translate '{value}': {e}[/yellow]")
|
console.print(f"[yellow]Warning: Failed to translate '{value}': {e}[/yellow]")
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user