No. No. Yeah. So, here's the big difference. With HTML, because all the metadata for each of these posts is stored in the head of the file. So, if we look over at one of these files, you see we have our title here, our name, we have our title here, our excerpt, and then down at the bottom we have all our content. And we want to translate this. Well, by default, when you send an HTML file through, it's not going to translate the head. So, instead, that has to be part of our process. So, inside of our function, you see here that we're parsing the document, and this is after the translation's been done. So, we're taking the translated file and we're parsing through it and then what we're doing is we're going through the head in order to get all the metatags and then we're specifically looking for the title and the excerpt. And once we find it, we're sending it through our translate function to get it translated into the destination language. And after that's all done, then we're reassembling our head, including that translated metadata, and then we're replacing the translated file with the new translated file that also has the translated head.
So, if we jump back over to our Markdown version, this is where it's pretty different, because in here, after we do the initial translation, you'll see that we don't have a second step of needing to translate the head. However, what we do have is we have to translate, we still have to translate the metadata separately. And this is actually an issue that I ran into with Azure AI Translator, where it has, it attempts to translate the front matter. So, if we look at one of these posts, all this section, if you're unfamiliar, all of this section is metadata in our Markdown file. And so, it attempts to translate it, but I've run into several issues. So, I've run into issues where this period gets moved outside of the quote, which will prevent this file from loading. And also, I've run into issues where it tries to translate some of the keys in the objects, and then also, it tries to translate some of the words in the URL, like path itself. And so, this obviously causes it all to break. And so, in our translation function, it's an interesting setup. So, we have to translate not the destination files, so like the translated files, front matter, because it's actually unparsable right now because of some of the issues. So, what we actually have to do is we have to parse and then translate the original files metadata and then put that translated metadata in with the translated files content in order to get it matched up. And so, that's what you're seeing right here, where we're replacing or using regex to find the front matter, and we're replacing it with the input files translated metadata. And then, after that, then we're uploading. And so, this is how it all works.
So, now, if we jump over to GitHub, we can actually look at the GitHub actions workflow running. And so, here's the HTML version. And so, you see, first, we provision the Azure resources.
Comments