Migrating from a Monolith to Microservices: A Step-by-Step Guide
This article is a step-by-step guide on how to migrate from a Monolith to Microservices
As part of our project, we needed a translation management tool. We have 3 languages on our site, and the translations are done by the business team (marketing and other).
Localise.biz (aka Loco) is a SaaS online translation management service. It offers free and paid subscriptions according to the needs and the size of the project.
First, we need to create a user account. Once our account is created, we start by creating a project and choose a main language for this project which will serve as a basis for translations. The same user can be part of several projects.
We can then add all the languages we need in our application, whether it be in a standard format, ISO2, or custom languages for more specific needs.
The interface is quite simple and intuitive. With all the filters availables, it becomes easy to work on this interface without any issues.
Here are the reasons that convinced us to choose this tool.
Loco allows you to manage statuses for assets (an asset is a translation key associated with its translations in all languages).
This allows us to set up a rather simple translation validation workflow. For example, when the development team creates translation keys, they can put them into Provisional status.
Then, when the translations have been done and validated by the people whose responsibility it is, the status is modified, allowing to filter on the assets that are to be translated yet, thus simplifying their work.
Moreover, it is possible to assign tags to assets. This was useful for us to prepare releases in particular.
Of course, when migrating to a new solution, we do not want to create the translation keys one by one... Loco has a very complete import / export system with a wide range of formats (JSON, CSV, etc.). We can also use all the filters in our exports. I'll let you take a look at their documentation with all the details if needed.
The main reason to choose Loco for us was the REST API. It allows to manipulate all the data that we are able to modify with the UI (translations, locales, tags ...). In our case, we used only the retrieval of translations.
When translation files are stored within an application, we sometimes have to deploy it only to update certain translations.
When redesigning our website, we decided to store the translation files on a cloud storage to separate the deployment of our applications from the translations update.
Thus, we export the contents of Loco to store it in a bucket on Google Cloud Platform in JSON files (one file per language). So we have set up a cron that runs regularly on Google App Engine that takes care of that.
Below is the code:
const axios = require('axios');
const express = require('express');
const { Storage } = require('@google-cloud/storage');
const app = express();
const storage = new Storage({
projectId: 'GOOGLE_CLOUD_PLATEFORM_PROJECT_ID',
});
app.get('/translations/b2cwebsite', (req, res,) => {
const bucket = storage.bucket('YOUR_BUCKET_NAME');
const locales = ['en', 'fr'];
let status = 200;
const client = axios.create({
baseURL: 'https://localise.biz',
headers: {'Authorization': 'Loco YOUR_LOCALISE_API_KEY'}
});
locales.forEach(function(locale) {
client.get('/api/export/locale/' + locale + '.json')
.then(function (response) {
const file = bucket.file(`messages.${locale}.json`);
file.save(JSON.stringify(response.data), {
contentType: 'application/json',
public: true,
gzip: true,
resumable: false,
metadata: {
cacheControl: `public, max-age=3600`,
},
}, function(err) {
if (err) {
console.error(`Couldn't upload translations file to Google Cloud Storage for locale ${locale}: ${err}`);
status = 500;
}
});
})
.catch(function (error) {
console.error(`Couldn't fetch translations from Localise for locale ${locale}: ${error}`);
status = 500;
});
});
res.status(status).end();
});
As you can see, in just a few lines we get our translation files. Just load them into our app and you're done!
If you are working on a multi-language site and you are looking for a solution that would satisfy both developers and translators, Localise.biz could be right for you. This solution offers great flexibility, both in the way you manage and export translations, and in the way you manage translations on a daily basis for business users.
Author(s)
Marie Minasyan
Astronaute Raccoon @ ElevenLabs_🚀 De retour dans la Galaxie.
You wanna know more about something in particular?
Let's plan a meeting!
Our experts answer all your questions.
Contact usDiscover other content about the same topic
This article is a step-by-step guide on how to migrate from a Monolith to Microservices
You work with Symfony, but the concept of dependency injection is a little blurry for you? Find out how to take advantage of the component reading this article.
Today is the International Women's Rights Day, and we wanted to take the opportunity to talk to you about a subject that is close to our hearts: women in IT. The purpose of this article is to tell you about our experience to give you a better vision of why there aren't many of us, why some give up, and, above all, how to make that change.