pokecarde/scripts/gen3text.py
pokegold-spaceworld 1f99a55607 Localization Changes / Additional Card Support
- Improvements to build, which should help find nevpk and rgbds a little easier.
- Support for berry cards K007-K012 has been added (original Japanese) and they have received unofficial localizations.
- Unofficial Localizations for cards B001 - B048 have now been included.
- Cards P001-P004 have now been added (Official English and Japanese)
- Cards P005-P008 have now been added (official Japanese) and have also received unofficial localizations.
- Cards N001-N008 have now been added (official Japanese) and have also received unofficial localizations.
- Unofficial localization for card O001 has been improved to be more in-line with official localizations of the time.

tl;dr All Ruby/Sapphire e-Reader cards are now included and exist in their original English/Japanese, and have unofficial localizations if no official translation is available.
2023-07-09 20:43:08 -04:00

482 lines
7.9 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
#!/usr/bin/env python2.7
import sys
chars = {
# Japanese character table
' ': '\x00',
'': '\x01',
'': '\x02',
'': '\x03',
'': '\x04',
'': '\x05',
'': '\x06',
'': '\x07',
'': '\x08',
'': '\x09',
'': '\x0A',
'': '\x0B',
'': '\x0C',
'': '\x0D',
'': '\x0E',
'': '\x0F',
'': '\x10',
'': '\x11',
'': '\x12',
'': '\x13',
'': '\x14',
'': '\x15',
'': '\x16',
'': '\x17',
'': '\x18',
'': '\x19',
'': '\x1A',
'': '\x1B',
'': '\x1C',
'': '\x1D',
'': '\x1E',
'': '\x1F',
'': '\x20',
'': '\x21',
'': '\x22',
'': '\x23',
'': '\x24',
'': '\x25',
'': '\x26',
'': '\x27',
'': '\x28',
'': '\x29',
'': '\x2A',
'': '\x2B',
'': '\x2C',
'': '\x2D',
'': '\x2E',
'': '\x2F',
'': '\x30',
'': '\x31',
'': '\x32',
'': '\x33',
'': '\x34',
'': '\x35',
'': '\x36',
'': '\x37',
'': '\x38',
'': '\x39',
'': '\x3A',
'': '\x3B',
'': '\x3C',
'': '\x3D',
'': '\x3E',
'': '\x3F',
'': '\x40',
'': '\x41',
'': '\x42',
'': '\x43',
'': '\x44',
'': '\x45',
'': '\x46',
'': '\x47',
'': '\x48',
'': '\x49',
'': '\x4A',
'': '\x4B',
'': '\x4C',
'': '\x4D',
'': '\x4E',
'': '\x4F',
'': '\x50',
'': '\x51',
'': '\x52',
'': '\x53',
'': '\x54',
'': '\x55',
'': '\x56',
'': '\x57',
'': '\x58',
'': '\x59',
'': '\x5A',
'': '\x5B',
'': '\x5C',
'': '\x5D',
'': '\x5E',
'': '\x5F',
'': '\x60',
'': '\x61',
'': '\x62',
'': '\x63',
'': '\x64',
'': '\x65',
'': '\x66',
'': '\x67',
'': '\x68',
'': '\x69',
'': '\x6A',
'': '\x6B',
'': '\x6C',
'': '\x6D',
'': '\x6E',
'': '\x6F',
'': '\x70',
'': '\x71',
'': '\x72',
'': '\x73',
'': '\x74',
'': '\x75',
'': '\x76',
'': '\x77',
'': '\x78',
'': '\x79',
'': '\x7A',
'': '\x7B',
'': '\x7C',
'': '\x7D',
'': '\x7E',
'': '\x7F',
'': '\x80',
'': '\x81',
'': '\x82',
'': '\x83',
'': '\x84',
'': '\x85',
'': '\x86',
'': '\x87',
'': '\x88',
'': '\x89',
'': '\x8A',
'': '\x8B',
'': '\x8C',
'': '\x8D',
'': '\x8E',
'': '\x8F',
'': '\x90',
'': '\x91',
'': '\x92',
'': '\x93',
'': '\x94',
'': '\x95',
'': '\x96',
'': '\x97',
'': '\x98',
'': '\x99',
'': '\x9A',
'': '\x9B',
'': '\x9C',
'': '\x9D',
'': '\x9E',
'': '\x9F',
'': '\xA0',
'': '\xA1',
'': '\xA2',
'': '\xA3',
'': '\xA4',
'': '\xA5',
'': '\xA6',
'': '\xA7',
'': '\xA8',
'': '\xA9',
'': '\xAA',
'': '\xAB',
'': '\xAC',
'': '\xAD',
'': '\xAE',
'': '\xAF',
'': '\xB0',
'': '\xB1',
'': '\xB2',
'': '\xB3',
'': '\xB4',
'': '\xB5',
'': '\xB6',
'': '\xB7',
'': '\xB8',
'×': '\xB9',
'': '\xBA',
'': '\xBB',
'': '\xBC',
'': '\xBD',
'': '\xBE',
'': '\xBF',
'': '\xC0',
'': '\xC1',
'': '\xC2',
'': '\xC3',
'': '\xC4',
'': '\xC5',
'': '\xC6',
'': '\xC7',
'': '\xC8',
'': '\xC9',
'': '\xCA',
'': '\xCB',
'': '\xCC',
'': '\xCD',
'': '\xCE',
'': '\xCF',
'': '\xD0',
'': '\xD1',
'': '\xD2',
'': '\xD3',
'': '\xD4',
'': '\xD5',
'': '\xD6',
'': '\xD7',
'': '\xD8',
'': '\xD9',
'': '\xDA',
'': '\xDB',
'': '\xDC',
'': '\xDD',
'': '\xDE',
'': '\xDF',
'': '\xE0',
'': '\xE1',
'': '\xE2',
'': '\xE3',
'': '\xE4',
'': '\xE5',
'': '\xE6',
'': '\xE7',
'': '\xE8',
'': '\xE9',
'': '\xEA',
'': '\xEB',
'': '\xEC',
'': '\xED',
'': '\xEE',
'': '\xEF',
'': '\xF0',
'Ä': '\xF1',
'Ö': '\xF2',
'Ü': '\xF3',
'ä': '\xF4',
'ö': '\xF5',
'ü': '\xF6',
#'⬆': '\xF7',
#'⬇': '\xF8',
#'⬅': '\xF9',
'\\l': '\xFA',
'\\p': '\xFB',
'\{FC}': '\xFC',
'\\v1': '\xFD\x01',
'\\v2': '\xFD\x02',
'\\v3': '\xFD\x03',
'\\n': '\xFE',
'@': '\xFF',
# characters changed for Western versions
' ': '\x00',
'À': '\x01',
'Á': '\x02',
'Â': '\x03',
'Ç': '\x04',
'È': '\x05',
'É': '\x06',
'Ê': '\x07',
'Ë': '\x08',
'Ì': '\x09',
'Î': '\x0B',
'Ï': '\x0C',
'Ò': '\x0D',
'Ó': '\x0E',
'Ô': '\x0F',
'Œ': '\x10',
'Ù': '\x11',
'Ú': '\x12',
'Û': '\x13',
'Ñ': '\x14',
'ß': '\x15',
'à': '\x16',
'á': '\x17',
'ç': '\x19',
'è': '\x1A',
'é': '\x1B',
'ê': '\x1C',
'ë': '\x1D',
'ì': '\x1E',
'î': '\x20',
'ï': '\x21',
'ò': '\x22',
'ó': '\x23',
'ô': '\x24',
'œ': '\x25',
'ù': '\x26',
'ú': '\x27',
'û': '\x28',
'ñ': '\x29',
'º': '\x2A',
'ª': '\x2B',
'\{er}': '\x2C',
'&': '\x2D',
'+': '\x2E',
'\{L.}': '\x34', # Italian
'\{Lv}': '\x34', # English
'\{Lv.}': '\x34', # German
'\{N.}': '\x34', # French
'\{Nv}': '\x34', # Spanish
'=': '\x35',
';': '\x36', # European
'¿': '\x51',
'¡': '\x52',
'\{PKMN}': '\x53\x54',
'\{POKé}': '\x55\x56',
'\{POKéBLOC}': '\x55\x56\x57\x58\x59', # French
'\{POKéBLOCK}': '\x55\x56\x57\x58\x59', # English
'\{POKéCUBO}': '\x55\x56\x57\x58\x59', # Spanish
'\{POKéRIEGEL}': '\x55\x56\x57\x58\x59', # German
'Í': '\x5A',
'%': '\x5B',
'(': '\x5C',
')': '\x5D',
'\{POKéMELLA}': '\x5E\x5F\x60\x61\x62', # Italian
'\{POKéMELLE}': '\x5E\x5F\x60\x61\x63', # Italian
'â': '\x68',
'í': '\x6F',
'': '\x79',
'': '\x7A',
'': '\x7B',
'': '\x7C',
'\{e}': '\x84', # European
'': '\x85', # European
'': '\x86', # European
'\{re}': '\xA0', # European
'0': '\xA1',
'1': '\xA2',
'2': '\xA3',
'3': '\xA4',
'4': '\xA5',
'5': '\xA6',
'6': '\xA7',
'7': '\xA8',
'8': '\xA9',
'9': '\xAA',
'!': '\xAB',
'?': '\xAC',
'.': '\xAD',
'-': '\xAE',
'': '\xB0',
'': '\xB1', # English, Italian, Spanish
'«': '\xB1', # French
'': '\xB1', # German
'': '\xB2', # English, Italian, Spanish
'»': '\xB2', # French
#'“': '\xB2', # German — clashes with English B1
'': '\xB3',
'': '\xB4',
'$': '\xB7',
',': '\xB8',
'/': '\xBA',
'A': '\xBB',
'B': '\xBC',
'C': '\xBD',
'D': '\xBE',
'E': '\xBF',
'F': '\xC0',
'G': '\xC1',
'H': '\xC2',
'I': '\xC3',
'J': '\xC4',
'K': '\xC5',
'L': '\xC6',
'M': '\xC7',
'N': '\xC8',
'O': '\xC9',
'P': '\xCA',
'Q': '\xCB',
'R': '\xCC',
'S': '\xCD',
'T': '\xCE',
'U': '\xCF',
'V': '\xD0',
'W': '\xD1',
'X': '\xD2',
'Y': '\xD3',
'Z': '\xD4',
'a': '\xD5',
'b': '\xD6',
'c': '\xD7',
'd': '\xD8',
'e': '\xD9',
'f': '\xDA',
'g': '\xDB',
'h': '\xDC',
'i': '\xDD',
'j': '\xDE',
'k': '\xDF',
'l': '\xE0',
'm': '\xE1',
'n': '\xE2',
'o': '\xE3',
'p': '\xE4',
'q': '\xE5',
'r': '\xE6',
's': '\xE7',
't': '\xE8',
'u': '\xE9',
'v': '\xEA',
'w': '\xEB',
'x': '\xEC',
'y': '\xED',
'z': '\xEE',
':': '\xF0',
}
asmProblemBytes = ['\x00', '\x09', '\x0A', '\x22']
def utf8ToRSText(t, region = ""):
currentChars = chars
if region == "DE":
chars[''] = '\xB2'
characters = []
char = ""
while len(t):
if ord(t[0]) >= 0xF0:
char += t[0:4]
t = t[4:]
elif ord(t[0]) >= 0xE0:
char += t[0:3]
t = t[3:]
elif ord(t[0]) >= 0xC0:
char += t[0:2]
t = t[2:]
else:
char += t[0:1]
t = t[1:]
if char != "\\" and char != "\\v" and (char[0:2] != "\\{" or char[-1] == "}"):
characters.append(char)
char = ""
result = ""
for char in characters:
result += chars[char]
return result
def asmQuote(t):
result = ""
quoted = False
if t[0] in asmProblemBytes:
result = '{0}'.format(ord(t[0]))
else:
result = '"' + t[0]
quoted = True
while len(t):
if quoted and t[0] in asmProblemBytes:
result += '",{0}'.format(ord(t[0]))
quoted = False
elif quoted:
result += t[0]
elif t[0] in asmProblemBytes:
result += ',{0}'.format(ord(t[0]))
quoted = False
else:
result += ',"' + t[0]
quoted = True
t = t[1:]
if quoted:
result += '"'
return result