CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

Tool Translator++ 4.9.28 Standard Version / Developer Version

5.00 star(s) 1 Vote

jaden_yuki

Active Member
Jul 11, 2017
931
708
I just opened the addon options and saw that even addons that rely on third-party repos like GPT4All are restricted. wow! is there a hub of addons developed by the community?
 
Oct 21, 2022
50
5
Hello guys
I just want to ask that can I customize translate engine to use my own API ?
Here is a translate file python code using my custom API
Python:
import requests
import re
import json

# Path to the text file on your computer
raw_path = "cntd.txt"
text_path = "cntd(translated).txt"

# Function to read content from a text file on the computer
def read_file_content(file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            content = file.readlines()  # Read file by line
        return content
    except FileNotFoundError:
        print(f"File {file_path} does not exist.")
        return None

# Function to write content to a file
def write_file_content(file_path, content):
    try:
        with open(file_path, 'a', encoding='utf-8') as file:
            file.write(content + "\n")  # Add newline after each piece of content
        print(f"Result has been written to file {file_path}")
    except Exception as e:
        print(f"An error occurred while writing to the file: {e}")

# Function to send an API request
def send_api_request(text_content):
    url = "https://api.dichnhanh.com/"
    
    # Form data you provided
    # type: "Modern", "Ancient"
    data = {
        "type": "Ancient",
        "enable_analyze": 1,
        "enable_fanfic": 0,
        "mode": "qt",
        "text": text_content,  # Text content from file
        "remove": ""
    }
    
    # Send POST request to API
    try:
        response = requests.post(url, data=data)
        if response.status_code == 200:
            return response.text
        else:
            print(f"Error {response.status_code}: {response.text}")
            return None
    except Exception as e:
        print("An error occurred:", e)
        return None

# Capitalize the first letter immediately after a newline
def capitalize_after_newline(text):
    lines = text.split('\n')  # Split text by newline
    capitalized_lines = []
    special_characters = ['(', '( ', "'", '"', '|', '[', '“', '【', '【 ', '《', '《 ']  # Special characters

    for line in lines:
        line = line.strip()  # Remove leading and trailing spaces
        if line:  # If the line is not empty
            if line[0] in special_characters and len(line) > 1:
                # If the first character is special, capitalize the character right after it
                capitalized_line = line[0] + line[1].upper() + line[2:]
            else:
                # If there's no special character, capitalize the first character
                capitalized_line = line[0].upper() + line[1:]
            capitalized_lines.append(capitalized_line)
        else:
            capitalized_lines.append(line)  # If the line is empty, keep it as is

    return '\n'.join(capitalized_lines)

# Function to process and write results from the API
def write_result(response_text, text_path):
    # Parse JSON
    response_json = json.loads(response_text)

    # Get the text content from the 'content' key
    raw_content = response_json['data']['content']

    # Replace <br> or <p> tags with newline \n
    content_with_newline = re.sub(r'<br\s*/?>|</p>', '\n', raw_content)

    # Remove HTML tags (span, br, ...) using regex
    cleaned_content = re.sub(r'<[^>]+>', '', content_with_newline)

    # Apply capitalization processing function
    final_content = capitalize_after_newline(cleaned_content)

    # Print the processed result
    write_file_content(text_path, final_content)

# Function to split the file into smaller chunks
def split_content_into_chunks(content, chunk_size=100):
    for i in range(0, len(content), chunk_size):
        yield ''.join(content[i:i+chunk_size])  # Join the lines into a string

# Read file content
text_content = read_file_content(raw_path)

# If file is not empty, split the content and send each chunk
if text_content:
    for chunk in split_content_into_chunks(text_content):
        response = send_api_request(chunk)
        if response:
            write_result(response, text_path)
 

jaden_yuki

Active Member
Jul 11, 2017
931
708
Hello guys
I just want to ask that can I customize translate engine to use my own API ?
Here is a translate file python code using my custom API
Python:
import requests
import re
import json

# Path to the text file on your computer
raw_path = "cntd.txt"
text_path = "cntd(translated).txt"

# Function to read content from a text file on the computer
def read_file_content(file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            content = file.readlines()  # Read file by line
        return content
    except FileNotFoundError:
        print(f"File {file_path} does not exist.")
        return None

# Function to write content to a file
def write_file_content(file_path, content):
    try:
        with open(file_path, 'a', encoding='utf-8') as file:
            file.write(content + "\n")  # Add newline after each piece of content
        print(f"Result has been written to file {file_path}")
    except Exception as e:
        print(f"An error occurred while writing to the file: {e}")

# Function to send an API request
def send_api_request(text_content):
    url = "https://api.dichnhanh.com/"
   
    # Form data you provided
    # type: "Modern", "Ancient"
    data = {
        "type": "Ancient",
        "enable_analyze": 1,
        "enable_fanfic": 0,
        "mode": "qt",
        "text": text_content,  # Text content from file
        "remove": ""
    }
   
    # Send POST request to API
    try:
        response = requests.post(url, data=data)
        if response.status_code == 200:
            return response.text
        else:
            print(f"Error {response.status_code}: {response.text}")
            return None
    except Exception as e:
        print("An error occurred:", e)
        return None

# Capitalize the first letter immediately after a newline
def capitalize_after_newline(text):
    lines = text.split('\n')  # Split text by newline
    capitalized_lines = []
    special_characters = ['(', '( ', "'", '"', '|', '[', '“', '【', '【 ', '《', '《 ']  # Special characters

    for line in lines:
        line = line.strip()  # Remove leading and trailing spaces
        if line:  # If the line is not empty
            if line[0] in special_characters and len(line) > 1:
                # If the first character is special, capitalize the character right after it
                capitalized_line = line[0] + line[1].upper() + line[2:]
            else:
                # If there's no special character, capitalize the first character
                capitalized_line = line[0].upper() + line[1:]
            capitalized_lines.append(capitalized_line)
        else:
            capitalized_lines.append(line)  # If the line is empty, keep it as is

    return '\n'.join(capitalized_lines)

# Function to process and write results from the API
def write_result(response_text, text_path):
    # Parse JSON
    response_json = json.loads(response_text)

    # Get the text content from the 'content' key
    raw_content = response_json['data']['content']

    # Replace <br> or <p> tags with newline \n
    content_with_newline = re.sub(r'<br\s*/?>|</p>', '\n', raw_content)

    # Remove HTML tags (span, br, ...) using regex
    cleaned_content = re.sub(r'<[^>]+>', '', content_with_newline)

    # Apply capitalization processing function
    final_content = capitalize_after_newline(cleaned_content)

    # Print the processed result
    write_file_content(text_path, final_content)

# Function to split the file into smaller chunks
def split_content_into_chunks(content, chunk_size=100):
    for i in range(0, len(content), chunk_size):
        yield ''.join(content[i:i+chunk_size])  # Join the lines into a string

# Read file content
text_content = read_file_content(raw_path)

# If file is not empty, split the content and send each chunk
if text_content:
    for chunk in split_content_into_chunks(text_content):
        response = send_api_request(chunk)
        if response:
            write_result(response, text_path)
you'll have to create your own addon
 

tanlianmax

New Member
Jun 15, 2022
2
0
After I translate the text, the small pattern on the left suddenly disappears, how can I restore it?
View attachment 4166512
↑ after
View attachment 4166516
↑ before
[/引用]
你翻译了系统引导字符,假如<New>代表引导使用这个图标,你把New翻译后,引导就无法触发,你在翻译的时候也需要把这个图案文件的名称改为被引导触发的名称才会生效。 "New"只是个举例!
第一个办法,你需要找到并改写图案名字与引导词搭配来触发图案
第二个办法,你再进行一次翻译,跳过关键引导词来维持图案的触发。
 
Last edited:

Dark Pixel

Member
Nov 28, 2022
119
356
Sisulizer 4
Information was shared by a Buddy with the nickname (Alex(GoD)):


1) Open your project in Translator++:
Once you have opened your project, press Ctrl+H in the main window of the programme to bring up a box, select ‘Search’ .

2) Select ‘Context’:
In the upper right corner of the box where it says ‘Target’, select ‘Context’.

1.png

3) Find /message/ and tag it:
In the search box, type /message/ and press Enter. (This may take some time).
Click ‘Select all.’ Then right click on any of the entries found.
Select ‘With selection’ and then ‘Set Green Tag’.

2.png

4) Repeat the process (Set Green Tag) for /Show Choices/ :
Similarly, find /Show Choices/ and set ‘Set Green Tag’ for all of them.

Note: This usually covers about 95% of the game text, except for things like character names, items, skills, menu options, and lines in plugins.

At this stage, anything that needs translation is marked with a green tag. You can move all these green lines to a separate column.

5) Select the relevant files:
Select all MapXXX files, as well as the CommonEvents and Troops files. (CommonEvents and Troops files may contain translatable lines).

6) Create an automation script:
Right-click any selected file on the left (For example: on Map001). Select ‘With (number) selected’ -> ‘Create automation’ -> ‘For each row’.

3.png

7) Paste and run the following script: (this will move all green tagged rows to the Initial column)

if (this.tags.includes("green")) {
this.cells[1] = this.cells[0];
}


4.png


It's done.

5.png

Save the project.

Good luck with your translations!!!

Translated with (free version)
 

Yuki-x

Member
Jul 22, 2021
225
350
Just a warning in case you use vpn's with "split tunelling" (some apps go through the vpn, while others go through your normal network).

Translator++ will use both of them and if your firewall is not configured correctly:
- block private network and allow domain/public networks, if you want translator++ to go through the vpn tunnel or
- allow private network and block domain/public networks, if you want translator++ to go through the real connection

...your vpn connection will be compromised both on dreamsavior's server and on the patreon site...
 
Oct 21, 2022
50
5
hello guys
anybody here have translator++ with Baidu translate inside?
I see Baidu work really good in case of translating from japanese or chinese to vietnamese(my native language)
 
5.00 star(s) 1 Vote