VNTranslator
Become a PatronJoin Our Discord
  • Overview
  • GETTING STARTED
    • Getting Started
    • System Requirements
    • Download & Installation
    • Interface Basics
  • Features
    • Launcher
    • Modules
    • Translation
      • Translation Settings
      • Translation Glossary
      • Extra Options
        • Pre-translation
        • Post-translation
        • Variables
      • Transcheck
      • Advanced Settings
      • Translation Editor
      • Export Translation
      • Import Translation
    • MT Engines
      • MT Settings
      • DeepL API
      • OpenAI Translate (Legacy)
    • Extra Window
    • Hyper Overlay
    • Extensions
      • JParser
      • Jisho
      • Fast OCR
    • Hotkeys
  • User Guide
    • Clipboard
    • OCR
      • Features
        • OCR Screen
        • OCR Master
        • Pre-processing
        • OCR Engines
          • Tesseract OCR
          • Windows OCR
          • Google Cloud Vision
          • Azure Cloud Vision
          • Google Lens
          • Custom - Command Line
          • Custom - HTTP POST
        • Post-processing
      • OCR Engine Installer
      • Understanding OCR and Improving Accuracy
      • OCR Engines Comparison
    • OCR GX 🎮
    • AutoTrans
      • Translation Modes
      • Font Replacement
      • Feature Settings
        • Translation
        • Mods
      • Extract & Translate
      • Steam Connect
      • RTL
      • FAQ
        • How Can I Improve Game Speed in AutoTrans?
        • How to Change Font Type in RenPy?
        • How to Change Font Size in Unity?
    • RenPy Games
    • Tyrano Builder
    • TextractorCLI
  • ADVANCED
    • LLMs
      • System Prompt
      • OpenAI API
      • GeminiAI API
    • Custom MT
      • Schema
      • Form Builder
      • Request & Response
      • Components
      • webLLM
      • MT Kit
      • V1 & V2 (Archive)
    • OCR Server Kit
      • EasyOCR
      • SuryaOCR
    • API Gateway
      • Translate
      • Translation Memory 🚧
    • RegExp
      • Matching
      • Replacement
  • Help
    • FAQ
    • Troubleshooting
      • Launcher
        • VNTranslator appears as a black box
      • Network Connection
      • Machine Translation (MT)
        • Web Scraping Timeout
        • API Error Codes
        • Clear Cookies & Site Data
      • OCR
      • AutoTrans
      • TextractorCLI
    • Glossary
    • Archives
      • Comparison of OCR Version 1.0 and 2.0
      • Workflow Explanation for OCR
      • OCR 1.0 (Archive)
        • Tesseract OCR
        • Screen Capture
        • Post-Capture Actions
    • Credits
Powered by GitBook
On this page
  • Variables
  • Parameters
  • method: string
  • url: string
  • encodeURI: string (optional)
  • encodeURIComponent: string (optional)
  • encodeURIExtra: string (optional)
  • initialUrl: string (optional)
  • userAgent: string (optional)
  • querySelector: string
  • querySelectorAll: string (optional)
  • queryProperty: string
  • body: object
  • options: object (optional)
  • responseType: string
  • responseQuery: string
  • JSON Response from HTTP Request
  • Examples
  • 1. Web Scraping Method - Object Structure
  • 2. HTTP GET Method- Object Structure
  • 3. HTTP POST Method - Object Structure
  1. ADVANCED
  2. Custom MT

Request & Response

The core configuration of Machine Translation Request

Variables

  • $ID

  • $SOURCE_TEXT

  • $ORIGINAL_TEXT

  • $TRANSLATED_TEXT

  • $SOURCE_LANG

  • $TARGET_LANG

You can use schema variables in the configuration with syntax $SCHEMA_NAME For example:

{
    "schema": [
        { "type": "string", "name": "api_key", "title": "API Key", "default": "", "required": true, "message": "Required an API Key" },
    ],
    "request": {
        "method": "http_post",
        "url": "http://127.0.01/?key=$API_KEY"
        "options": {
            "headers": {
              "Authorization": "Bearer $API_KEY",
              "Content-Type": "application/json"
            }
        }        
    }
}

Parameters

method: string

  • web_scraping

  • http_get

  • http_post

  • web_llm

url: string

encodeURI: string (optional)

encodeURIComponent: string (optional)

encodeURIExtra: string (optional)

Additional function to replace URI with regexp string. For example: "["%2F", "g", "\\%2F"]"

initialUrl: string (optional)

userAgent: string (optional)

querySelector: string

querySelectorAll: string (optional)

queryProperty: string

body: object

options: object (optional)

  • headers - set request headers

    • X-Custom-Header: string

    • Authorization: string

    • Content-Type: string

responseType: string

  • string - set response type as string

  • json - set response type as json

responseQuery: string


JSON Response from HTTP Request

You can parse the JSON Response with ResponseQuery

The responseQuery is only used for http_get and http_post methods with the response type as JSON

A JSON object is an associative array. The location path syntax to navigate into an arbitrarily deeply nested structure of JSON objects comprises the field names separated by dot '.' delimiters.

For example the following JSON Response

{
  "text": "Hello 1",
  "words": [
    { "text": "Hello 2" },
    { "text": "Hello 3" }
  ]
  "lines": {
    "text": "Hello 4",
    "sub": {
      "text": "Hello 5"
    }        
  }
}
responseQuery
Result

text

Hello 1

words[0].text

Hello 2

lines.sub.text

Hello 5



Examples

1. Web Scraping Method - Object Structure

  • method: string

  • encodeURI: boolean

  • encodeURIComponent: boolean

  • encodeURIExtra: string

  • url: string

  • initialUrl: string

  • querySelector: string

  • querySelectorAll: string

  • queryProperty: string

{
    "request": {
        "method": "web_scraping",
        "encodeURI": false,
        "encodeURIComponent": true, 
        "initialUrl": "https://localhost:8080",
        "url": "https://localhost:8080/?sl=$SOURCE_LANG&tl=$TARGET_LANG&text=$SOURCE_TEXT",    
        "querySelector": "span[lang=$TARGET_LANG]",
        "querySelectorAll": null,                
        "queryProperty": "innerText"
    }
}

2. HTTP GET Method- Object Structure

  • method: string

  • encodeURI: boolean

  • encodeURIComponent: boolean

  • encodeURIExtra: string

  • url: string

  • options: object

  • responseType: string

  • responseQuery: string

{
    "request": {
        "method": "http_get",
        "encodeURI": false,
        "encodeURIComponent": false, 
        "url": "https://localhost:8080/translate?sl=$SOURCE_LANG&tl=$TARGET_LANG&text=$SOURCE_TEXT",
        "options": {},
        "responseType": "string"  
    }
}

3. HTTP POST Method - Object Structure

  • method: string

  • encodeURI: boolean

  • encodeURIComponent: boolean

  • encodeURIExtra: string

  • url: string

  • body: object

  • options: object

    • headers: object

      • X-Custom-Header: string

      • Authorization: string

      • Content-Type: string

  • responseType: string

  • responseQuery: string

{
    "request": {
        "method": "http_post",
        "encodeURI": false,
        "encodeURIComponent": false, 
        "url": "https://localhost:8080/translate",
        "body": {
            "text": "$SOURCE_TEXT",
            "source_lang": "$SOURCE_LANG",
            "target_lang": "$TARGET_LANG"
        }
        "options": {
            "headers": {
                "Authorization": "Bearer $API_KEY",
                "Content-Type": "application/json"
            }
        },
        "responseType": "json",
        "responseQuery": "translate.result"
    }
}
PreviousForm BuilderNextComponents

Last updated 4 months ago

Escapes characters by UTF-8 code units, with each octet encoded in the format %XX, left-padded with 0 if necessary. Because lone surrogates in UTF-16 do not encode any valid Unicode character.

Uses the same encoding algorithm as described in encodeURI. It escapes all characters except: A–Z a–z 0–9 - _ . ! ~ * ' ( )

Return the first Element within the HTML that matches the specified selector, or group of selectors.

return a static (not live) NodeList representing a list of the HTML elements that match the specified group of selectors.

value - property of the HTMLDataElement

innerText - property of the HTMLElement

innerHTML - property of the HTMLElement

textContent - property of the Node

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataElement/value
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent