Skip to content

Instantly share code, notes, and snippets.

@MDTravisYT
Last active October 25, 2024 01:08
Show Gist options
  • Save MDTravisYT/c8c4b965098adb7eb1a851e7a7b93051 to your computer and use it in GitHub Desktop.
Save MDTravisYT/c8c4b965098adb7eb1a851e7a7b93051 to your computer and use it in GitHub Desktop.
Gen 1 Pokemon source localization string to source code string translator
# ▒▒▒▒▒▒▒▓██▒▒▒▓████▒▒███▓▒▒▓██▒▒▒▒████████████▓▒▒
# ▒▒▒▒▒▒▓███▒▒▓█████▓▓███▓▒▒██▒▒██▒▒▓████████████▒
# ▒▒▒▒▒▓████▒▓██████▒▒██▒▒▒▒▒▓▓██▒▒▒▒▒▒▒███▓▒▒▒▒▒▒
# ▒▒▒▒▓█████████████▓▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓███▒▒▒▒▒▒
# ▒▒▒▓██████████████▒▒██▒▒▒▒▓█████▒▒▒▒▒▒▒███▓▒▒▒▒▒
# ▒▒▓███████████████▓▓███████████▓▒▒▒▒▒▒▒▓███▒▒▒▒▒
# ▒▓████████████████▒▒█████████▓▒▒▒▒▒▒▒▒▒▒███▓▒▒▒▒
# ░░░░░░░░░░░░░░░░░░░░MDTRAVIS░░░░░░░░░░░░░░░░░░░░
# #==============================================#
# | Python tool that converts standard text from |
# | the Pokemon localization documents into |
# | compilable text for the game. This is useful |
# | for restoring older versions of the text |
# | strings without manually having to translate |
# | them. |
# | |
# | ---<USAGE>--- |
# | Input the text into a file called "input.txt"|
# | Run the script, and the output will be at |
# | "output.txt". |
# | |
# | --<EXAMPLE INPUT>-- |
# | A slot machine!{home@} |
# | Want to play?{EOMeom} |
# #==============================================#
txt = ""
uppercases = ("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
lowercases = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
numbers = ("0","1","2","3","4","5","6","7","8","9",)
flagMode = False
out = " db "
newline = out
f = open("input.txt")
for x in (f.read()):
txt = txt+x
f.close()
for x in txt:
if flagMode == True:
if x == "I_MSG":
break
if x == "}":
flagMode = False
out = out+"\n"+newline
continue
if x == ",":
out = out+"\n"+newline
continue
else:
out = out+x
continue
for y in uppercases:
if x == y:
out = out+"usf_"+x.lower()+","
for y in lowercases:
if x == y:
out = out+"usf_"+x+"_,"
for y in numbers:
if x == y:
out = out+"n"+x+"@\n"+newline
if x == " ":
out = out+"spc@\n"+newline
if x == "!":
out = out+"gyoe@\n"+newline
if x == "?":
out = out+"hate@\n"+newline
if x == ".":
out = out+"kten@,"
if x == ",":
out = out+"comma@,"
if x == ":":
out = out+"colon2@,"
if x == "-":
out = out+"bou@,"
if x == "`":
out = out+"`"
if x == "{":
flagMode = True
out = out.replace("`usf_","apt_")
out = out.replace("\n db I_MSG","\n db EOM\n db I_MSG")
out = out.replace("db town_name","dw town_name\n db D_MSG")
out = out.replace("db leader_name","dw leader_name\n db D_MSG")
out = out.replace("db dealer_name","dw dealer_name\n db D_MSG")
out = out.replace("db dealer_mons_no","dw dealer_mons_no\n db D_MSG")
out = out.replace("db enemy_data","dw enemy_data\n db D_MSG")
out = out.replace("db table_data","dw table_data\n db D_MSG")
out = out.replace("db str_buf","dw str_buf\n db D_MSG")
out = out.replace("db gein_name","dw gein_name\n db D_MSG")
out = out.replace("db anime_buf + 0\n db 013h","dw anime_buf + 0\n db 013h\n db D_MSG")
out = out.replace("db anime_buf + 1\n db 013h","dw anime_buf + 1\n db 013h")
out = out.replace("N_MSG","\n db EOM\n db N_MSG")
out = out.replace("EOM^1","EOM")
out = out.replace("EOM^2","EOM,EOM")
f = open("output.txt","w")
f.write(out[:-5])
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment