Korozin / JGecko-XML-Translator

Tired of manually translating Japanese code list, so... automationnnnnn!! :3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JGecko-XML-Translator

This is a Python script that reads an input XML file and translates the Japanese text found in the name, comment, and author tags to English using the Googletrans API. The translated XML file is saved as output.xml.

Example of input / output XMLs can be found here

Dependencies

This script requires the following dependencies:

  • re
  • sys
  • time
  • colorama
  • googletrans
  • xml.etree.ElementTree

Usage

  1. Make sure that all dependencies are installed.
  2. Place the input XML file that needs to be translated in the same directory as the script. The input XML file should have the name input.xml.
  3. Run the script using the command python Gecko-XML-Translator.py.
  4. The translated XML file will be saved as output.xml.
  5. The script will log all translation activity and errors to the console output.

Graceful Exit Handling

This script includes graceful exit handling using signal.SIGINT on Unix-based systems and ctypes.windll.kernel32 on Windows systems. This enables the user to exit the script using CTRL + C without the risk of data corruption.

Script Description

  1. The script first removes the encoding statement from the input XML file, if it exists. This is done to avoid encoding statement errors.
  2. The script then creates a translator object using the Googletrans API.
  3. The script parses the input XML file using xml.etree.ElementTree.
  4. The script loops through each entry in the input XML file.
  5. For each entry, the script checks if the name, comment, and author tags contain Japanese text.
  6. If any of these tags contain Japanese text, the script translates the text to English using the Googletrans API.
  7. The translated text is then saved to the corresponding tag in the output XML file.
  8. If the Googletrans API encounters an error during translation, the script logs the error to the console output and continues with the next entry.

Error Handling

If the Googletrans API encounters an error during translation, the script logs the error to the console output and continues with the next entry. The script also logs a message to the console output if it fails to set up signal handling.

README generated by ChatGPT AI

About

Tired of manually translating Japanese code list, so... automationnnnnn!! :3


Languages

Language:Python 100.0%