Skip to content

Commit

Permalink
update trans.py
Browse files Browse the repository at this point in the history
  • Loading branch information
naya1503 committed Mar 2, 2024
1 parent f08a04f commit e4f76a9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions trans.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import asyncio

import yaml
from gpytranslate import Translator


async def translate_text(text):
translator = Translator()
translated_text = await translator.translate(text, source="id", target="en")
translated_text = await translator.translate(text, source='id', target='en')
return translated_text


async def translate_yaml(input_file, output_file):
with open(input_file, "r", encoding="utf-8") as file:
with open(input_file, 'r', encoding='utf-8') as file:
data = yaml.safe_load(file)

tasks = []
Expand All @@ -32,8 +29,7 @@ async def translate_yaml(input_file, output_file):

print("Translated Data:", translated_data) # Print translated data

with open(output_file, "w", encoding="utf-8") as file:
with open(output_file, 'w', encoding='utf-8') as file:
yaml.dump(translated_data, file, allow_unicode=True)


asyncio.run(translate_yaml("langs/strings/id.yml", "langs/strings/en.yml"))
asyncio.run(translate_yaml('langs/strings/id.yml', 'langs/strings/en.yml'))

0 comments on commit e4f76a9

Please sign in to comment.