While driving home in the evening, I came up with an interesting project, and by two o’clock in the morning, I had finished it. Now I have an English-language blog — RaufAliev.com. All the posts on it are automatically translated from Facebook, which, as I wrote a couple of days ago, are also published on beinginamerica.com.
Translating the archive takes time (and slightly eats $$$), and so far by 2 a.m. translations are done for the last two years, but the process is still ongoing, and I hope soon all 5000 will be translated.
Some technical details: translation via ChatGPT-4. All content is exported into a file, one line per post. Each post starts with a prefix like this (2024-04-22T07:59:18.json). Then, this file is divided into fragments of no more than X kilobytes each (I chose 10). It is then sent to the OpenAI API with the prompt “Translate to English preserving my style and keeping the HTML markup. Each line starts with a json filename in parentheses. Your output should be formatted in the same way – each line should be started with the same, but the text should be translated to English. Below is the text”. The result is recorded in a translation file. Then, I run the same script that created my Facebook posts on beinginamerica, but now I publish it on another WordPress site, and I use the translated content instead of the original.
In addition, I have connected the LinkPreview API service to pull an image and title from the link if it is in the post, making it look nicer. This post on raufaliev.com should pull up Hi, I’m Rauf Aliev.
A separate script transfers my new posts. This one, for example, it’s not in the archive which I made a week ago. The JSON format of Facebook’s latest posts is slightly different, but more or less the same. We extract the latest posts, check if there are any images, if yes, download them, check if they were not uploaded on beinginamerica, if not, upload them, then check if the post has been previously published on beinginamerica, if not, publish it, then translate it into English using OpenAI, then beautify the links using the LinkPreview API, then check if it was not yet uploaded on the English site. If not – upload it.
https://raufaliev.com/