Astfel, vei putea face un client multi-language in cateva minute.
Exemplu:
Tutorial:
Continut: Ascuns
Trebuie sa multumesti autorului pentru a putea vedea mesajul.
Trebuie sa multumesti autorului pentru a putea vedea mesajul.


Cod: Selectaţi tot
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()
niceManiacRobert scrie: ↑29 Ian 2023, 00:14 Citeste locale_game al tau și locale_game după official, ce ai în plus, le mută in ex, după te poți folosi ușor de traducerile din official
Cod: Selectaţi tot
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()
Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 8 vizitatori