Using Artificial Intelligence (AI) to translate the blog posts

After 1 year of going live with the blog maybe it is time to work on some enhancements? I guess so... the problem is... which enhancements? There are several things I wanted to make it better, some are easy to handle and some are more complex. Which of the ideas will generate more impact? Where should I start?

It always come to prioritization and I decided to prioritize the list of things to improve based mainly on feedback I got from friends and readers during the past year and how hard/easy it is to implement some of the ideas.

Here are a few easy/quick things I did:

  • Updated the Search functionality and added a menu item for "Search" (the icon was not working properly on some phones)
  • Made some enhancements around Search Engine Optimization (SEO) and added the site map to the Google Search Console
  • I have deleted the default WordPress user when I created the blog but security is never enough so I changed the wp-admin url to something hopefully is not easily accessible. That is a great tip that came from a friend who also started writing: Azrael Garden.
  • One day a colleague said "Oh you have a blog? let me check! Well... I'm getting a 503 error here" (if you don't know what 503 means I suggest you check out the HTTP status dogs). To avoid getting embarrassed again, I've added monitoring to get notified when the blog is down. Remember that I'm a cheap guy so I decided to use the free tier of UptimeRobot for that

Time to go over one complex thing to enhance. I already noticed that at least half of the blog visitors come from Brazil, here are some data on page views from the previous month: Brazil - 72, USA - 42 and Rest of the world - 21. Also, more than once, I got some comment around publishing the blog content Portuguese but, if you read the "Hello World" post, you noticed that one of the reasons I created the blog was to "keep up with my English writing". With that, English is settled for writing, but is there a way to easy translate the blog posts to Portuguese and make it available on the blog? I don't want to write each blog post twice (one in English and the another version in Portuguese) so it is time to do some tests and use some translation mechanism!

The easiest way would be to look for a WordPress plugin. Quick google search and indeed there is a plugin that can do it all but I don't like having the translation part at the end of my write-commit-review-publish workflow. If you recall, I'm using markdown files and storing every post in GitHub (see Blog Decisions for more) so I want to do something there in the beginning of my workflow.

Here is my initial thought: Automatically translate all the markdown files that I have in my GitHub blog repository and generate new pt-br.md for each file.

But, before even thinking on automating and create this new translating/publishing step in my workflow, of course I have questions... Am I going to learn something new? Are the translations good or just garbage? Will I have to intervene manually on the translated results? How much, just a bit or a lot? How can I implement this multi language support in WordPress? What blog URL structure should I use to enhance SEO? And the most difficult of all questions: is it worth it? Will people read the Portuguese posts? (see, More questions = Better Decisions). It is time for some testing before even thinking about automating everything and a new state of the art workflow!

There is no point in trying to answer all those questions if I don't like the Artificial Intelligence (AI) translations so let's start there. In the automation scenarios I had in my head most of them involved calling an existing Application Programming Interface (API) to do the translation. Luckily, there are several APIs available that does exactly that, some free, some paid, some with free tiers... so many options! I selected the ones available in the three major cloud providers to test (sorry IBM cloud!):

ProviderPricing Free TierPaid TierDocumentation
GoogleFirst 500,000 characters per month are free on Basic plan (applied as $10.00 credit every month)$20.00 per million characters (assuming that 10 dollars are applied as credit every month you actually pay $10.00)Google Cloud Translation
Azure2 million characters of standard translation free per month$10.00 per million characters of standard translationAzure Cognitive Services Translator
AWS2 million characters free per month for 12 months$15.00 per million charactersAmazon Translate

Oh god, here we go again and face the pain of putting in credit card information in each cloud provider just to get an API key for a free tier test!

As this is a test just to check if the translations are "good enough" I'm using the previous post (Diagram as Code) as a guinea pig so just sending the markdown content to the available APIs using Postman.

Google API

Well... ChatGPT is on the hype right now so why not send a request for translation there as well? I could use their available API but I don't want to pay for it (for now!). I know my test won't scale and I will not be able to automate without the API but I just want to check it out😁.

Damn

After some waiting, you know, free tier and probably too much LinkedIn influencers trying to create posts with ChatGPT I was able to get in. It started translating but it stopped in the 5th paragraph (probably because I reached the free tier characters limit) and when I asked the prompt to continue translating something interesting happened: It started creating content in Portuguesa that I haven't written in the English post:

Hallucination

I knew I wouldn't be able to use it and it was just a test out of curiosity but this was a great case of Hallucination which is common in Large Language Model (LMM) AI such as ChatGPT. Anyway, back to the problem, before reading all three results and saying "Ok I can live with that" I decided to translate one paragraph myself and compare it with the three API results:

Original ParagraphMy TranslationGoogle APIAzure APIAWS APIChatGPT prompt
The first and the most important thing that comes to my mind when talking about diagrams in the software industry is: we need to create (or adjust) diagrams according to the target audience. Seems obvious, but sometimes we need to state the obvious, so here we go with an example: please don't present a UML (Unified Modeling Language) class diagram to a senior executive who just want to have a grasp on how your application works and integrates with the rest of the world. That means that using one-diagram-to-rule-them-all as a strategy won't work.A primeira e mais importante coisa que me vem à mente quando falamos de diagramas na indústria de software é: precisamos criar (ou ajustar) os diagramas de acordo com a audiência. Parece óbvio, mas as vezes o óvbio precisa ser dito, então vamos lá com um exemplo: por favor não apresente um diagrama de classe UML (Unified Modeling Language) para um executivo sênior que só quer ter uma idéia de como sua aplicação funciona e como ela se integra com o resto do mundo. Isso significa que usar um-unico-diagrama-mestre como estratégia não vai funcionar.A primeira e mais importante coisa que me vem à cabeça quando se fala em diagramas na indústria de software é: precisamos criar (ou ajustar) diagramas de acordo com o público-alvo. Parece óbvio, mas às vezes precisamos dizer o óbvio, então aqui vamos com um exemplo: por favor, não apresente um diagrama de classe UML (Unified Modeling Language) para um executivo sênior que só quer entender como seu aplicativo funciona e se integra com o resto do mundo. Isso significa que usar um diagrama para governar todos como estratégia não funcionaráA primeira e mais importante coisa que me vem à mente quando falo de diagramas na indústria de software é: precisamos criar (ou ajustar) diagramas de acordo com o público-alvo. Parece óbvio, mas às vezes precisamos afirmar o óbvio, então aqui vamos com um exemplo: por favor, não apresente um diagrama de classe UML (Unified Modeling Language) para um executivo sênior que só quer ter uma compreensão de como seu aplicativo funciona e se integra com o resto do mundo. Isso significa que usar um diagrama para governá-los como uma estratégia não funcionará.A primeira e mais importante coisa que me vem à mente quando falo sobre diagramas na indústria de software é: precisamos criar (ou ajustar) diagramas de acordo com o público-alvo. Parece óbvio, mas às vezes precisamos dizer o óbvio, então vamos dar um exemplo: por favor, não apresente um diagrama de classes UML (Unified Modeling Language) a um executivo sênior que só quer ter uma ideia de como seu aplicativo funciona e se integra ao resto do mundo. Isso significa que usar um diagrama para governar todos eles como estratégia não funcionará.A primeira e mais importante coisa que me vem à mente ao falar sobre diagramas na indústria de software é: precisamos criar (ou ajustar) diagramas de acordo com o público-alvo. Parece óbvio, mas às vezes precisamos afirmar o óbvio, então aqui vai um exemplo: por favor, não apresente um diagrama de classes UML (Unified Modeling Language) a um executivo sênior que só quer ter uma noção de como sua aplicação funciona e se integra com o resto do mundo. Isso significa que usar um único diagrama como estratégia não funcionará.

If you are curious and want to check out the entire post translations, here are they:

I actually read all the three translations checking each of the paragraphs against the original post and my final thoughts on this whole experiment are:

  • Reading carefully the table above, we can notice some slightly differences on the translations between the providers and mine. The "one-diagram-to-rule-them-all" phrase was something that I didn't like in any of the translations (well, to be honest ChatGPT did a ok job on it) and would be something that I would have to intervene manually and update the translation if I decide to go forward with those auto-translations
  • Because I sent the entire post for translation, some of the results doesn't make sense and I would never translate. Some examples:
    • Some product names like: "Mermaid" became "Sereia", "Backstage" got translated to "Bastidores" and the title of the YouTube video "The architect elevator: Connecting the boardroom and IT" turn into "O arquiteto elevador: conectando a sala de reuniões e TI"
    • Some parts of the post code blocks were translated as well which means it would never compile or work, here it is the Python Diagrams example: "from diagrams import Diagram, Node, Edge" was translated to "de diagramas importar Diagrama, Nó, Borda"
  • Regarding the 3 services, I probably spent more time setting up them, managing resource groups, projects, subscriptions, access, API keys, etc... for each cloud provider than actually testing! Sometimes I feel like this is by design just to make it harder for you to switch or test services.
  • The overall quality I would classify as "good" and the improvements are huge compared to where we were 5 years ago with this kind of AI bases translations. Is it perfect? No. will manual interventions be needed? Yes.

Now that I think the auto-translations are good to go - not so straightforward, it will require some pre-reading and a few manual interventions - it is time to move on to the next and most intriguing question: if I create those Portuguese posts, will people read and interact more? Do readers want translated posts?

This probably deserve it's own post... 🤔

Leave a Comment

Your email address will not be published. Required fields are marked *