This is a Argos Translate GO Endpoint
Go to file
Falko Victor Habel 40849e0fbb BugFix related to uft8 2024-06-21 09:39:35 +02:00
data rm .csv reading and switched to direct package reading 2024-03-16 11:21:40 +01:00
translator rm .csv reading and switched to direct package reading 2024-03-16 11:21:40 +01:00
LICENCE Switched to open Source 2024-03-16 18:02:03 +01:00
README.md improved readme File and removed unnessasary part in reply 2024-05-14 18:46:44 +02:00
go.mod changed Project Settings 2024-03-16 18:05:59 +01:00
main.go BugFix related to uft8 2024-06-21 09:39:35 +02:00
requirements.txt improved readme File and removed unnessasary part in reply 2024-05-14 18:46:44 +02:00

README.md

Translator-GO-Endpoint

This documentation provides an overview and setup guide for a Go-based server designed to handle translation tasks with streaming support. The application leverages Python scripts for actual translation and package management functionalities, taking advantage of both Go's robust HTTP serving capabilities and Python's extensive libraries.

Overview

The server offers an API endpoint to handle translation requests. It supports streaming of translation processes and package downloads, improving real-time feedback for end-users. It checks whether the necessary language packages are installed and initiates a download if they are missing, before proceeding with the translation.

Features

  • Streaming Translations: Utilizes server-sent events (SSE) to stream translation and download progress to the client.
  • Package Management: Automatically checks for the required language packages and downloads them if not present.
  • Language Support Checking: Validates if the requested language pairs are installed locally.

Getting Started

Prerequisites

Ensure you have the following installed:

  • Go (version 1.15 or higher)
  • Python (version 3.6 or higher)
  • Python packages required by the translator scripts

Setup

  1. Clone the Repository: Clone or download the source code to your local machine.
  2. Install Required Python Packages: Navigate to the translator directory and install necessary Python packages using pip:
pip install -r requirements.txt
  1. Running the Server: From the root directory of the project, start the server with the following command:
go run main.go
  • alternativly: Convert to exectuable via:
go build main.go

The server listens on port 53184 by default, but you can set the port variable, inside the main.go File, to use a different port.

API Usage

To perform a translation, send a JSON-formatted POST request to /api with the following structure:

{
  "message": "Hello, world!",
  "from": "en",
  "to": "de"
}
  • message: The text you wish to translate.
  • from: The source language code (ISO 639-1 format).
  • to: The target language code (ISO 639-1 format).

Request Example:

Request:

 curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello, world!", "from": "en", "to": "de"}' "http://localhost:53184"

Reply:

{"from":"en","to":"de","createdAt":"2024-05-14T16:32:36Z","response":"Hallo, Welt!"}

License

This project is licensed under the Attribution-NoDerivatives 4.0 International license - see the LICENSE file for details.