diff --git a/modules/csv.py b/modules/csv.py index bc6b86b..c16f843 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -76,7 +76,7 @@ BAR_FORMAT = "{l_bar}{bar:10}{r_bar}{bar:-10b}" POSITION = 0 LEAVE = False PBAR = None -ENCODING = "cp932" +ENCODING = "utf8" def handleCSV(filename, estimate): @@ -125,7 +125,7 @@ def openFiles(filename, writeFile): def openFilesEstimate(filename): - with open("files/" + filename, "r", encoding="cp932") as readFile: + with open("files/" + filename, "r", encoding="utf8") as readFile: translatedData = parseCSV(readFile, "", filename) return translatedData @@ -188,11 +188,11 @@ def parseCSV(readFile, writeFile, filename): totalLines = len(readFile.readlines()) readFile.seek(0) - reader = csv.reader(readFile, delimiter=",") + reader = csv.reader(readFile, delimiter="\t") if not ESTIMATE: writer = csv.writer( writeFile, - delimiter=",", + delimiter="\t", ) else: writer = "" @@ -338,8 +338,8 @@ def translateCSV(data, pbar, writer, filename, translatedList, format): # Speaker & Text Format case "4": # Set columns to translate. Leave empty to translate all. - speakerColumn = 8 - textColumn = 20 + speakerColumn = 2 + textColumn = 9 speaker = "" if len(data[i]) > textColumn and data[i][textColumn]: diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 2d19569..f1f7605 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -568,7 +568,9 @@ def searchNames(data, pbar, context): if len(nameList) < BATCHSIZE: nameList.append(data[i]["name"]) if "description" in data[i] and data[i]["description"] != "": - descriptionList.append(data[i]["description"].replace("\n", " ")) + description = data[i]["description"] + # description = description.replace("\n", " ") + descriptionList.append(description) if "") totalTokens[0] += tokensResponse[0] @@ -807,7 +809,7 @@ def searchNames(data, pbar, context): data[j]["name"] = translatedNameBatch[0] translatedNameBatch.pop(0) if "description" in data[j] and data[j]["description"] != "": - translatedDescriptionBatch[0] = textwrap.fill(translatedDescriptionBatch[0], LISTWIDTH) + # translatedDescriptionBatch[0] = textwrap.fill(translatedDescriptionBatch[0], LISTWIDTH) data[j]["description"] = translatedDescriptionBatch[0] translatedDescriptionBatch.pop(0) @@ -931,6 +933,7 @@ def searchCodes(page, pbar, jobList, filename): code = codeList[i]["code"] j = i endtag = "" + instantLineFlag = False # Grab String if len(codeList[i]["parameters"]) > 0: @@ -985,6 +988,13 @@ def searchCodes(page, pbar, jobList, filename): jaString, ) + # Colons + if len(speakerList) == 0: + speakerList = re.findall( + r"[\\]*[cC]?\[?\d*\]?(.+):$", + jaString, + ) + # First Line Speakers if len(speakerList) == 0 and FIRSTLINESPEAKERS is True: # Remove any RPGMaker Code at start @@ -1146,6 +1156,11 @@ def searchCodes(page, pbar, jobList, filename): finalJAString = finalJAString.replace("\\ac", "") CLFlag = True + # Handle Formatting Codes + if "\\>" in finalJAString: + instantLineFlag = True + finalJAString = finalJAString.replace("\\>", "") + # Pass 1 (Grabbing Data) if setData: # Remove Textwrap @@ -1197,6 +1212,11 @@ def searchCodes(page, pbar, jobList, filename): elif FIXTEXTWRAP is True: translatedText = textwrap.fill(translatedText, width=WIDTH) + # Formatting Code + if instantLineFlag: + translatedText = translatedText.replace("\n", "\n\\>") + translatedText = f"\\>{translatedText}" + # BR Flag if BRFLAG is True: translatedText = translatedText.replace("\n", "
") @@ -1261,7 +1281,7 @@ def searchCodes(page, pbar, jobList, filename): ## Event Code: 122 [Set Variables] if "code" in codeList[i] and codeList[i]["code"] == 122 and CODE122 is True: # This is going to be the var being set. (IMPORTANT) - if codeList[i]["parameters"][0] not in list(range(0, 99999)): + if codeList[i]["parameters"][0] not in list(range(150, 160)): i += 1 continue @@ -1288,9 +1308,9 @@ def searchCodes(page, pbar, jobList, filename): # continue # Validate Japanese Text - if not re.search(LANGREGEX, jaString): - i += 1 - continue + # if not re.search(LANGREGEX, jaString): + # i += 1 + # continue # Set String matchedText = None @@ -1321,7 +1341,7 @@ def searchCodes(page, pbar, jobList, filename): translatedText = re.sub(r'(?