Skip to content

This is a webapp that lets users upload text files, choose source and target languages and download a translated version of the files.

Notifications You must be signed in to change notification settings

msoegiarto/final-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Txtrans (Machine translation for txt file)

Description

This is a webapp that lets users upload text files, choose source and target languages and download a translated version of the files.

Site

https://txtrans.herokuapp.com/

Installation

  1. Fork and clone the repo

  2. Create a file .env file in the root folder

    AUTH0_DOMAIN=<your_auth0_domain>.auth0.com
    AUTH0_AUDIENCE=<your_homepage_url>
    
    MONGO_URI=mongodb://<host>:<port>/<database_name>
    
    MS_TRANSLATION_TEXT_SUBSCRIPTION_KEY=<your_microsoft_translation_api_key>
    MS_TRANSLATION_TEXT_ACCESS_TOKEN_URL=<your_microsoft_access_token_url>
    MS_TRANSLATION_TEXT_BASE_URL=<microsoft_translation_api_endpoint>
    
  3. Create a file .env.local in client/

    REACT_APP_AUTH0_DOMAIN=<your_auth0_domain>.auth0.com
    REACT_APP_AUTH0_AUDIENCE=<your_homepage_url>
    REACT_APP_AUTH0_CLIENTID=<your_auth0_client_id>
    REACT_APP_AUTH0_REDIRECT_URI=<redirect_uri_after_login>
    REACT_APP_AUTH0_RETURN_TO=<redirect_uri_after_logout>
    
    REACT_APP_TXTRANS_BASE_API=<your_backend_server> eg. http://localhost:5000
    
  4. Install the dependencies

    Server: npm install

    Client: npm run client-install

  5. Run the application

    Server: npm run server

    Client: npm run client

User flow

user_flow

Data Model

data_model

System table

table name = translations

columns type constraints
_id objectId PK
name string NN, U
time_interval number default 590000
time_last_requested number default 0
token string default ''

Built with

APIs

Microsoft Translator

Libraries

express

express-cors

express-fileupload

dotenv

jszip

qs

mongoDB

mongoose

react

material-ui

material-ui-dropzone

axios

Authentication

Auth0

Auth0 express-jwt

Auth0 jwks-rsa

Auth0 auth0-spa-js

Endpoints

Frontend

  1. / Landing Page

  2. /documents Documents Page

Backend

  1. POST /api/translate/documents/
    body: email, authentication
    

    If a user is login for the first time then persist the user to the database.

    If it’s an existing user, retrieve their saved documents (if any).

  2. POST /api/translate/documents/translate
    body: email, authentication, sourceLanguage, targetLanguage, file
    

    Get the texts from the user uploaded document and reshape those texts into an http request data and send them to a 3rd party translation API

    Save the result of the translation into the database

  3. POST /api/translate/documents/download
    body: email, authentication, nickname, translatedFileIds[]
    

    Retrieve the translated texts from the database and format those texts into a text file then send the file as an attachment

    If the download request is for multiple files, those files will be zipped before being sent

  4. POST /api/translate/documents/delete
    body: email, authentication, translatedFileIds[]
    

    Delete the saved document(s)

Nice to have

  1. User can choose multiple output languages

  2. Support more file formats

About

This is a webapp that lets users upload text files, choose source and target languages and download a translated version of the files.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published