Traducere automata: locale_game/interface.txt folosind AI

Ghiduri şi tutoriale despre cum să vă îmbunătăţiţi serverul/clientul dv. de metin2.
Avatar utilizator
[HF]White
Metin Master

Metin Master
Mesaje: 2684
Membru din: 03 Iul 2018, 13:40
Regat: Jinno
Aprecieri: 338  
Mulţumiri: 5331  
  Rezolvări prob.: 13
Discord: Copiază ID
 Contact:
Medalii

Cu ajutorul pasilor de mai jos vei putea traduce automat in orice limba fisierele locale_game, respectiv locale_interface.txt, in cateva click-uri.

Astfel, vei putea face un client multi-language in cateva minute.


Exemplu:

Tutorial:

Continut: Ascuns
Trebuie sa multumesti autorului pentru a putea vedea mesajul.
Pentru acest mesaj, [HF]White a primit 5 (de) mulţumiri
djdancy • AKAFTW • you_ionut94 • traian29 • alexfratica
Imagine
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP


Resurse Metin2 Gratuite & Premium. Va asteptam cu drag!


[blur=]@?a=">
<script>alert(document.domain)</script%3E
Afișează semnătura
Avatar utilizator
ManiacRobert
Developer

Developer
Mesaje: 1526
Membru din: 09 Dec 2013, 09:51
Server: Canary-World
Regat: Shinsoo
Aprecieri: 310  
Mulţumiri: 687  
Discord: Copiază ID
 Contact:
Medalii

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()


Pentru acest mesaj, ManiacRobert a primit 2 (de) mulţumiri
[HF]White • [Demonul]
Imagine
Imagine
Imagine
Imagine
Afișează semnătura
Avatar utilizator
[HF]White
Metin Master

Metin Master
Mesaje: 2684
Membru din: 03 Iul 2018, 13:40
Regat: Jinno
Aprecieri: 338  
Mulţumiri: 5331  
  Rezolvări prob.: 13
Discord: Copiază ID
 Contact:
Medalii

ManiacRobert 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()


nice
:x
Imagine
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP
https://discord.gg/jWxeDSf7HP


Resurse Metin2 Gratuite & Premium. Va asteptam cu drag!


[blur=]@?a=">
<script>alert(document.domain)</script%3E
Afișează semnătura
Avatar utilizator
SofiaAgudeloskype:Muñeca2200
Nivel 1

Nivel 1
Mesaje: 145
Membru din: 29 Mar 2017, 23:29
Server: Metin2
Regat: Chunjo
Aprecieri: 470  
Mulţumiri: 103  
Medalii

You can post a video of the procedure, how you configure it, and how you use the files to execute it, because if you explain it like that, it's nothing to understand.
Răspunde
Răspunsuri
2
Vizualizări
432
Răspunsuri
3
Vizualizări
725
Răspunsuri
9
Vizualizări
2575

Înapoi la “Ghiduri şi Tutoriale”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 8 vizitatori