Welcome to Metin2Resources

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Python Local Automatic Translation

RESOURCES HUB

Premium
Joined
Jul 22, 2025
Messages
84
Reaction score
93
Points
33
Location
London
Discord
jigsaw86
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

527Threads
968Messages
226Members
Ruben ChykaLatest member
Back
Top