Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

A web application for translating a set of words into another language using concurrency and an external translation service

License

Notifications You must be signed in to change notification settings

AlexanderGarifullin/ParallelTranslator

Repository files navigation

ParallelTranslator

Parallel Translator is a web application built with Java and Spring Boot for translating a set of words into another language using a third-party translation service MyMemory API. Each word is translated in separate threads with a maximum of 10 concurrent threads. The application also logs translation requests to a PostgreSQL database.

Technologies

  • Java 17
  • Spring Boot 3.3.2
  • PostgreSQL 16
  • JDBC
  • RestTemplate
  • Docker
  • HTML + JS

Requirements

  • Java 17
  • Maven
  • Docker and Docker Compose

Installation and Setup

  1. Clone the repository:

    git clone https://github.com/AlexanderGarifullin/ParallelTranslator.git
    cd ParallelTranslator
  2. Build the project using Maven:

    ./mvnw clean package
  3. Run the application using Docker Compose:

    docker-compose build --no-cache
    docker-compose up
  4. Shut down the application:

    docker-compose down

Usage

Once the application is running, it will be accessible at http://localhost:8080/api/translate.

Web Interface

Here is a screenshot of the main page of the web application:

Main Page Screenshot

If you navigate to a non-existent page, you will see a custom error page. For example, try visiting http://localhost:8080/nonexistent.

Error Page Screenshot

API Endpoints

Translate Text

  • Endpoint: /api/translate
  • Method: POST
  • Request Body:
    {
     "text": "your text here",
     "sourceLang": "en",
     "targetLang": "es"
    }
  • Response:
    "your translated text here"

Example

  1. Send a translation request:

    curl -X POST -H "Content-Type: application/json" -d '{"text": "hello world", "sourceLang": "en", "targetLang": "es"}' http://localhost:8080/api/translate
  2. Response:

    "hola mundo"

Accessing the Database

You can view the PostgreSQL database this way:

  1. Access the PostgreSQL container:

    docker exec -it postgres psql -U postgres -d TranslatorDB
  2. List all entries in api_translation_requests_logs:

    SELECT * FROM api_translation_requests_logs;
  3. Exit the PostgreSQL command line:

    \q

Viewing Javadoc

To view the Javadoc documentation:

  1. Generate Javadoc:

    Run the following Maven command to generate the Javadoc:

    ./mvnw javadoc:javadoc
  2. Navigate to the Javadoc directory:

    The Javadoc will be generated in the target/site/apidocs directory.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Additional Information

  • The application is designed to handle translation of individual words concurrently using up to 10 threads.
  • All translation requests are logged into the api_translation_requests_logs table with the following structure:
    • id (integer, primary key)
    • client_ip (varchar(45), not null)
    • text (text, not null)
    • translated_text (text, not null)
    • created_at (timestamp, default current timestamp)

Contact

For any issues or questions, please open an issue on GitHub or contact me.


© 2024 Alexander Garifullin. All rights reserved.

About

A web application for translating a set of words into another language using concurrency and an external translation service

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /