What's new
What's new

New messages New topics Systems Serverfiles 3D Models Web Scripting

Metin2Resources

👋 Welcome to Metin2 Resources — your hub for professional Metin2 server development.

Create a free account to access advanced systems, serverfiles, tutorials and connect with other developers.

🚀 Join today and start building better.

Python Local Automatic Translation

RESOURCES HUB

Premium
📜 Messages 304
👍 Reactions 2,256
🏆 Points 425
🌐 Website metin2global.to
Read locale_game of yours and locale_game after official, what you have extra, move them to ex, then you can easily use the translations from official.
merge_official_locales.py:
C++:
import os

locale_game_data = {}
locale_game_official_data = {}


def ReadFirstLocale(file_path: str):
    try:
        with open(file_path, "r") as f:
            lines = f.readlines()
            for line in lines:
                if "\t" in line:
                    key, *values = line.strip().split("\t")
                    locale_game_data[key] = values
    except Exception as e:
        print(f'An error occurred while reading {file_path}: {e}')


def ReadSecondLocale(file_path: str):
    try:
        with open(file_path, "r") as f:
            official_lines = f.readlines()
            for line in official_lines:
                if "\t" in line:
                    key, *values = line.strip().split("\t")
                    locale_game_official_data[key] = values
    except Exception as e:
        print(f'An error occurred while reading {file_path}: {e}')


def MergeLocales(output_file: str):
    diff_lines = []
    for key in locale_game_data:
        if key not in locale_game_official_data:
            diff_lines.append(key + '\t' + '\t'.join(locale_game_data[key]) + '\n')

    if os.path.exists(output_file):
        open(output_file, "w").close()
    else:
        open(output_file, "x").close()

    with open(output_file, "w") as f:
        for line in diff_lines:
            f.write(line)


def Start():
    print("Reading Client Locale")
    ReadFirstLocale("locale_game.txt")

    print("Reading Official Locale")
    ReadSecondLocale("locale_game_official.txt")

    print("Output _ex")
    MergeLocales("locale_game_ex.txt")


Start()
 

Latest posts

Back
Top Bottom