Write your Astro content in multiple languages

This week I shipped one of the biggest features in Darkmatter — support for writing content translated into multiple languages.

All you need to do is follow the official tutorial from the Astro team to set up internationalization. Darkmatter will detect the collections with translated entries and adapt the user interface to enable a special workflow to edit them.

src/content/blog/
  en/
    example-post.md
  fr/
    example-post.md

Once your folder structure looks like this, Darkmatter will start showing a “Language” dropdown on entry page to switch between translations in a click.

f99f091e-d44b-4f6b-a908-d1d1c2af478a.png

Need to translate content into more languages? Add another folder, name it with a language code and Darkmatter will do the rest.

There are no extra steps and most importantly, no configuration for you to deal with, inline with the entire spirit of Darkmatter.

Backstory

I have a small confession to make — this feature was literally at the very bottom of my to-do list and I didn’t think I’d need to build it for a long time.

However, John, one of the early adopters of Darkmatter, emailed me and asked when I’m going to ship it. John maintains many websites powered by Astro and internationalization support was a deal breaker for him. Naturally, I had no choice but to explore what I could do.

Problem is, there’s no dedicated API for defining content collections where entries have multiple translations. This means that there’s no sure way to determine whether content collection has translated content or just uses nested folders for organizing files neatly.

The only option that doesn’t involve configuration would be to look at the folder names inside src/content/blog and guess that they’re named after language codes. This would hint Darkmatter that this collection has translated content.

I didn’t like the sound of it. It felt flimsy and something that was bound to break sooner or later. At the same time, I really didn’t want to let John down. So I said fuck it, I’m going to at least try building it and see how it goes.

We started emailing back and forth, discussing how it could work and later that day, I shipped the exact vision I had in mind for content translation. After a few bug fixes, I’m happy to report it’s working really well and I’m excited about more people using it.

Thanks John for pushing me to build this! It’s been a lesson for me to prioritize customer’s needs above all else. I hope Darkmatter will serve you well 💛

Follow the development

Darkmatter is in active development and may launch next month. Follow the updates, get early access and watch the building process.

If email is not your thing, read the blog or follow on Twitter.