A copy of Google Translate's page for translating documents, with the addition that plain text files can also be translated.
google-cloud-translation-playground-demo.mp4
A Node.js server written using Express and socket.io, running on Cloud Run. It:
- Receives the translation request, creates a "translation job" record in Firestore.
- Uploads the file to the Cloud Storage bucket to trigger a translation.
- After the "translation job" has started, it connects to clients via socket.io to keep them updated about the "translation job's" status. To figure out that status, it gets realtime updates about the corresponding document.
- It provides a route for the user to downlod the translated document when the job is done.
A Cloud Function triggered by files being created in a GCS bucket. It:
- Uses the Cloud Translation API to translate the document.
- Uploads the translated file to another GCS bucket.
- Updates the "translation job's" status.
An user interface written using React, bootstrapped with create-react-app. It uses bulma as the main provider of components.
Be aware of the costs incurred by the running system, in particular:
- Cloud Load Balancing
- Translation API. This system makes use of the
Cloud Translation - Advanced
features.
The system is deployed using terraform
, running in Cloud Build.
- Create a Google Cloud Organization.
- Install
terraform
. - Install the
gcloud
CLI. - Have a domain and the ability to create
A Records
to connect that domain to the Load Balancer.
This is the process that creates the Google Cloud Project, enables the required APIs, and grants the necessary permissions to the Service Accounts, including the ones required for the Cloud Build Service Account to deploy the system.
- Run
gcloud auth login
- Run
gcloud auth application-default login
. cd
into the deployment/google-cloud/terraform/bootstrap folder.- Comment out the entire contents of the deployment/google-cloud/terraform/bootstrap/backend.tf file.
- Create a
terraform.tfvars
file and add your variables' values. Leave thesourcerepo_name
empty for now. - Run
terraform init
. - Run
terraform apply -target=module.project
. - Uncomment the deployment/google-cloud/terraform/bootstrap/backend.tf file's contents and add the value of the
tfstate_bucket
output as the value of thebucket
attribute. - Run
terraform init
and answeryes
. - Create a Cloud Source Repository in the project your just created. Optionally, fork this repository and create a Cloud Source Repository by mirroring your forked repo. Update the
sourcerepo_name
variable with the repository name. - Run
terraform apply
. - If you have errors related to granting permissions to the Google Storage Service Agent, you can go to your project's Google Cloud console, then go to Cloud Storage -> Settings and check for the presence of the Service Agent. Then re-run
terraform apply
.
This is a Cloud Build build that actually deploys the system.
- The pipeline can be triggered by either:
- Push a commit to your Cloud Source Repository or to your Github fork.
- Go to your project's Cloud Build Dashboard and manually run the
push-to-branch-deployment
trigger.
- After the build is successful, connect your domain to the Load Balancer.