Better debug, change check for japanese chars

This commit is contained in:
Dusk 2024-02-23 12:04:40 +01:00
parent ea4b17ee40
commit 8aa2fc6a3a
2 changed files with 18 additions and 3 deletions

View File

@ -85,7 +85,12 @@ def write_translated(outfile, origfile, translation_file_paths):
# --- Debug --- # --- Debug ---
global debug_current_line global debug_current_line
debug_current_line += 1 debug_current_line += 1
print("\n-", debug_current_line, transfilepath, tokens[0]) print(
"\n-",
debug_current_line,
transfilepath,
''.join(str(x) for x in tokens),
)
# ------------- # -------------
# Replace the text tokens with the translated ones # Replace the text tokens with the translated ones

View File

@ -17,7 +17,16 @@ class ScripterToken():
self.type = type self.type = type
def __str__(self): def __str__(self):
return f' |{self.token}|' if self.type == TokenType.TEXT:
color = '\033[34m'
elif self.type == TokenType.COMMAND:
color = '\033[32m'
elif self.type == TokenType.COMMENT:
color = '\033[36m'
return f'{color}{self.token}\033[0m'
def __repr__(self):
return self.__str__()
# Parse and tokenize an Nscripter script line in japanese mode # Parse and tokenize an Nscripter script line in japanese mode
@ -84,7 +93,8 @@ def is_double_width(char: str) -> bool:
] ]
for start, end in japanese_ranges: for start, end in japanese_ranges:
if start <= ord(char[0]) <= end: #if start <= ord(char[0]) <= end:
if 0xFF < ord(char[0]):
return True return True
return False return False