i'm completely new to chat gpt things. if i understood correctly then if i download tool i will still have to play for chat gpt to translate things to me or how does it work?
Yes, you will have to pay to use the API for GPT. The tool is also not very friendly to the average user. Need some dev skills to use it.
Ah I like to share this since I just started using your tool dazedanon some days ago!
There's a project called gpt4free which has chatgpt-4o API for free which I've been using!
They have multiple models (not just 4o) and it works really well!
However you'll have to edit the "extractTranslation" part of the dazedanon's dazedMTL modules code because sometimes the
response from the api has this in it's response:
Code:
json {
"Line1": "Kisaragi Merrie\n\"This place\nlooks like some kind of shop~♡\"",
"Line2": "Kisaragi Merrie\n\"If I had money, maybe I could buy something~♡\""
}
The issue being that "json" is the first line in the response (instead of starting with Line1), you'll get this error " extractTranslation Error: Expecting value: line 1 column 1 (char 0) on String" if you don't edit and add this code that I made!
Here's this code to make it work with extracting translations with that json as the first line, add it within the "extractTranslation" function:
Code:
# Ensure that the string starts with '{' and ends with '}', if not, attempt to find the JSON part
if not translatedTextList.strip().startswith("{") or not translatedTextList.strip().endswith("}"):
# Attempt to extract JSON-like content within the curly braces
PBAR.write(f"Attempting to extract valid JSON from: {translatedTextList}")
json_start = translatedTextList.find("{")
json_end = translatedTextList.rfind("}") + 1
if json_start != -1 and json_end != -1:
translatedTextList = translatedTextList[json_start:json_end]
else:
raise ValueError("No valid JSON content found")
If you're confused on where to add it, don't worry as I'll help ya out!
When you download the dazedMTL project, within the folder is called "modules".
Each module is made to translate various different games and formats!
So let's say you want to translate an RPGMaker MV/MZ game? Then you'll have to open the
"rpgmakermvmz.py" in a text editor like notepad++ (or notepad if you want), VSCode, etc and
then search for this text: "extractTranslation".
Once you find it, you'll have to insert the code I provided above within! Here's an example of my
edit of the currently updated rpgmakermvmz.py (as of writing this) function, and what it's supposed to look like:
Code:
def extractTranslation(translatedTextList, is_list):
try:
# Apply regex modifications as before
translatedTextList = re.sub(r'\\"+\"([^,\n}])', r'\\"\1', translatedTextList)
translatedTextList = re.sub(r"(?<![\\])\"+(?!\n)", r'"', translatedTextList)
# Ensure that the string starts with '{' and ends with '}', if not, attempt to find the JSON part
if not translatedTextList.strip().startswith("{") or not translatedTextList.strip().endswith("}"):
# Attempt to extract JSON-like content within the curly braces
PBAR.write(f"Attempting to extract valid JSON from: {translatedTextList}")
json_start = translatedTextList.find("{")
json_end = translatedTextList.rfind("}") + 1
if json_start != -1 and json_end != -1:
translatedTextList = translatedTextList[json_start:json_end]
else:
raise ValueError("No valid JSON content found")
# Load the JSON response
line_dict = json.loads(translatedTextList)
# If it's a batch (i.e., list), extract with tags; otherwise, return the single item.
# Extract the values
string_list = list(line_dict.values())
# Only print the raw response and detected translations when successful
PBAR.write(f"Successfully detected translation: {string_list}")
if is_list:
return string_list
else:
return string_list[0]
except Exception as e:
# In case of an error, this block will already print out the raw input
PBAR.write(f"extractTranslation Error: {e} on String {translatedTextList}")
return None
Once this is added, you'll be able to use gpt4free's api with no issue!
Now I've tested translating an RPGMaker MZ game and the translation works great!
I had to edit some text when I was translating just the system.json file though (sometimes
the api doesn't simply translate and instead explains what the japanese line means in english.)
But for everything else, it's works wonders!
Okay if you want to try gpt4free if you don't want to pay for chatgpt-4o, here's my instructions on how to run it below!
Project Link:
You must be registered to see the links
Make sure to have python 3.12+ (3.10+ for just gpt4free, but 3.12+ needed for dazedanon's tool) installed!
If you want to install it and test it right now, simply type this in a terminal/console window:
"pip install gpt4free[api]"
This will install the api only of gpt4free, if you want everything else that gpt4free has (web ui, etc)
then check the project page above for further instructions on that!
Anyways once that's done, edit your .env and put this in for the api url:
"http://localhost:1337/v1/"
Make sure that the api url has the / at the end and doesn't look like this!
"http://localhost:1337/v1"
Otherwise it won't work and you'll get errors!
and as for API Key, just type in any number in it (it can't be empty otherwise nothing will work when using the api).
#API key
key="1111"
Then for organization, just type "org-" followed by any word you want to use for it like in this example:
organization="org-CuteAndFunny"
Next, as for what to type in model, you can use chatgpt-4o with this:
and if you want to try other models (o1 and o1-mini is currently not working, but in the future it may work as gpt4free is updated so you can switch to that once chatgpt o1 becomes more available.)
Here's a direct link with the list of models to try out, they're all openai compatible but I haven't tested them all:
You must be registered to see the links
Now run "g4f api" in your terminal/console and api should be up and running hopefully!
Then run dazedanon's tool and translate away!