diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 811e66ac..00a5cbfc 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -530,16 +530,15 @@ def parsemayberegexreplace(dict, res): return res +def getlanguse(): + return static_data["language_list_translator_inner"][globalconfig["languageuse"]] + + def checkpostlangmatch(name): for item in static_data["transoptimi"]: if name == item["name"]: try: - return ( - static_data["language_list_translator_inner"][ - globalconfig["languageuse"] - ] - == item["languageuse"] - ) + return getlanguse() == item["languageuse"] except: return True diff --git a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py index fda64eac..d8918ee8 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py +++ b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py @@ -58,11 +58,23 @@ class TS(basetransdev): ) self.currenttext = content currtext = "" - while self.currenttext == content: - time.sleep(0.01) # get text before violate usage policies. + if self.tgtlang == "Arabic": - newcurr = self.getcurr(idx) - if newcurr == currtext: - continue - yield newcurr[len(currtext) :] - currtext = newcurr + while self.currenttext == content: + time.sleep(1) # get text before violate usage policies. + + newcurr = self.getcurr(idx) + needbreak = newcurr == currtext and newcurr != "" + currtext = newcurr + if needbreak: + break + yield currtext + else: + while self.currenttext == content: + time.sleep(0.01) # get text before violate usage policies. + + newcurr = self.getcurr(idx) + if newcurr == currtext: + continue + yield newcurr[len(currtext) :] + currtext = newcurr