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/
-
Fork and clone the repo
-
Create a file
.env
file in the root folderAUTH0_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>
-
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
-
Install the dependencies
Server:
npm install
Client:
npm run client-install
-
Run the application
Server:
npm run server
Client:
npm run client
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 '' |
APIs
Libraries
Authentication
Frontend
-
/
Landing Page -
/documents
Documents Page
Backend
-
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).
-
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
-
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
-
POST /api/translate/documents/delete body: email, authentication, translatedFileIds[]
Delete the saved document(s)
-
User can choose multiple output languages
-
Support more file formats