trickerer / Trinity-Bots

NPCBots for TrinityCore and AzerothCore 3.3.5
https://github.com/trickerer/TrinityCore-3.3.5-with-NPCBots/
446 stars 148 forks source link

+zh_CN readme, unify translate, fix punctuation. #787

Closed AreChen closed 1 month ago

AreChen commented 2 months ago

Added a Simplified Chinese readme(README_ZH.md) file, proofread and unified class & spell naming, and at the end of the Chinese readme file, I added the Netherbot addon that I fixed for Simplified Chinese players (including complete Chinese translation, command fixes, and the addition of the Crypt Lord).

Add npcbots names and titles translate.

image image

AreChen commented 2 months ago

The readme file language switch button is something I borrowed it from other projects. LOL If someone wants to add translations for other languages in the future, they can refer to the following code.

<p align="left">
  <a href="./README.md"><img alt="README in English" src="https://img.shields.io/badge/English-d9d9d9"></a>
  <a href="./README_CN.md"><img alt="简体中文版自述文件" src="https://img.shields.io/badge/简体中文-d9d9d9"></a>
  <a href="./README_JA.md"><img alt="日本語のREADME" src="https://img.shields.io/badge/日本語-d9d9d9"></a>
  <a href="./README_ES.md"><img alt="README en Español" src="https://img.shields.io/badge/Español-d9d9d9"></a>
  <a href="./README_FR.md"><img alt="README en Français" src="https://img.shields.io/badge/Français-d9d9d9"></a>
  <a href="./README_KL.md"><img alt="README tlhIngan Hol" src="https://img.shields.io/badge/Klingon-d9d9d9"></a>
</p>
AreChen commented 2 months ago

Here is a python script that provides a direct translation of the npcbots 'name' field in rows 70000 to 70595 of the 'creature_template' table using OpenAI GPT-3.5-turbo.

import mysql.connector
from openai import OpenAI
client = OpenAI()
#set target language
target_language = "chinese"
def translate_text(text, model="gpt-3.5-turbo"):
    # Use the OpenAI API for translation, you need to modify the prompt according to your own language.
    try:
        completion = client.chat.completions.create(
        model=model,
        messages=[
            {"role": "system", "content": f"Translate this English name: {text} into {target_language}. If you don't know how to translate, just make up a name. Do not return any text or punctuation marks unrelated to the name, only return the {target_language} name."}
        ]
        )
        print(completion.choices[0].message.content)
        return completion.choices[0].message.content
    except Exception as e:
        print(f"An error occurred during translation: {e}")
        return None

def main():
    # db config
    db_config = {
        'user': 'user',
        'password': 'passwword',
        'host': 'localhost',
        'database': 'acore_world',
        'raise_on_warnings': True
    }

    # db connect
    conn = mysql.connector.connect(**db_config)
    cursor = conn.cursor()

    # Select the 'name' field from rows 70000 to 70595.
    cursor.execute("SELECT entry, name FROM creature_template WHERE entry BETWEEN 70000 AND 70595")
    names_to_translate = cursor.fetchall()

    # Update the translated name
    for entry, name in names_to_translate:
        translated_name = translate_text(name)
        print(name)
        if translated_name:
            update_query = "UPDATE creature_template SET name = %s WHERE entry = %s"
            cursor.execute(update_query, (translated_name, entry))
            print(f"Updated entry {entry} with name {translated_name}")

    # Submit changes and close the connection.
    conn.commit()
    cursor.close()
    conn.close()

if __name__ == "__main__":
    main()
AreChen commented 1 month ago

Is there anything that I need to change?

trickerer commented 1 month ago

Ah sorry, this comment was supposed to be here a week ago, completely forgot about it.

I would request two things changed: 1) Rename creature_template_local_npcbots_zhCN.sql -> creature_template_locale.sql - there is no need for those file names to be different from the table name they refer to. 2) Please remove Readme translation. I was pondering this idea for some time but unlike in-game text localization, Readme translation has to be synchronized with the original 100% of the time and I can't guarantee that. And no, automatic translation won't do.

AreChen commented 1 month ago

Ah sorry, this comment was supposed to be here a week ago, completely forgot about it.

I would request two things changed:

  1. Rename creature_template_local_npcbots_zhCN.sql -> creature_template_locale.sql - there is no need for those file names to be different from the table name they refer to.
  2. Please remove Readme translation. I was pondering this idea for some time but unlike in-game text localization, Readme translation has to be synchronized with the original 100% of the time and I can't guarantee that. And no, automatic translation won't do.

1.done! 2.About Readme, I will regularly maintain it because I have been playing with it and need to always pay attention to whether there are new features and documents appearing. In addition, this Readme translation has been proofread manually after being translated by AI. Please consider adding it. If you still think it should be removed, I will remove it. Thank you!

trickerer commented 1 month ago

No, man, this won't work. There aren't only two languages in the world and new translations may get created in the future by different people. Other people's work should give me neither additional credit, not additional responsibility I can't take. Create npcbot readme translations repository if you want and I'll link it in the readme. If someone gets confused by the translation I'll send them your way.

As for my personal standpoint this readme is only supposed to help admins understand what they are looking at, not for player's reference really. And any admin should be able to read it in English and understand fully without any problems at all.

spoiler

My native language isn't English either.

AreChen commented 1 month ago

Got it