<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Buse Mağden</title>
    <description>The latest articles on DEV Community by Buse Mağden (@buse_magden).</description>
    <link>https://dev.to/buse_magden</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4255842%2Fd1c5a831-67fe-4c10-ae97-c49993a1afba.jpg</url>
      <title>DEV Community: Buse Mağden</title>
      <link>https://dev.to/buse_magden</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/buse_magden"/>
    <language>en</language>
    <item>
      <title>Self-hosted machine translation for 8 languages: what broke and the checks that catch it</title>
      <dc:creator>Buse Mağden</dc:creator>
      <pubDate>Fri, 20 Nov 2026 15:12:51 +0000</pubDate>
      <link>https://dev.to/buse_magden/self-hosted-machine-translation-for-8-languages-what-broke-and-the-checks-that-catch-it-28j1</link>
      <guid>https://dev.to/buse_magden/self-hosted-machine-translation-for-8-languages-what-broke-and-the-checks-that-catch-it-28j1</guid>
      <description>&lt;p&gt;We run &lt;a href="https://www.masqot.co/en/?utm_source=devto&amp;amp;utm_medium=makale&amp;amp;utm_campaign=yayin-havuzu&amp;amp;utm_content=20261120-ceviri" rel="noopener noreferrer"&gt;Masqot&lt;/a&gt;, a community platform for the tech ecosystem: members, communities, events and a blog. In October 2026 we made it available in eight languages: Turkish, English, German, Russian, Arabic, Spanish, French and Azerbaijani. Turkish is the source language for almost everything.&lt;/p&gt;

&lt;p&gt;There are two kinds of text, and we handled them differently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interface text&lt;/strong&gt; (buttons, menus, error messages) was translated once during development and stored in JSON files. The key is the Turkish string itself, so a missing translation falls back to Turkish instead of showing a key like &lt;code&gt;button.save&lt;/code&gt;. A check script flags any language that is missing a key or has a placeholder that doesn't match the source, and a change isn't done until it comes back clean.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User content&lt;/strong&gt; (posts, comments, event descriptions, community pages, blog posts) is translated automatically when someone reads it in another language. This part is what this post is about.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk3fs3b7u19ipblcy0ozy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk3fs3b7u19ipblcy0ozy.png" alt="Pipeline: Turkish source, cache lookup keyed by a hash of the source, name protection, self-hosted LibreTranslate, quality gate, then either its own indexed URL or noindex" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why self-hosted
&lt;/h2&gt;

&lt;p&gt;We chose &lt;a href="https://github.com/LibreTranslate/LibreTranslate" rel="noopener noreferrer"&gt;LibreTranslate&lt;/a&gt; running on our own server, reachable only from our internal network. The reason was data protection, not cost: member posts and profiles stay on our infrastructure, and we didn't add a new third party that receives personal data abroad. The provider sits behind a small interface (&lt;code&gt;translateText&lt;/code&gt;, &lt;code&gt;detectLanguage&lt;/code&gt;), so we can swap it later.&lt;/p&gt;

&lt;p&gt;Two rules were fixed from day one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Private messages are never translated. There is a database constraint that rejects them as a source type.&lt;/li&gt;
&lt;li&gt;A translation is stored once, keyed by a hash of the source text. If the source changes or is deleted, a trigger removes the stored translation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The quality is not at the level of commercial APIs. We knew that going in. What we underestimated was how many ways it can fail quietly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure 1: short titles came back in English
&lt;/h2&gt;

&lt;p&gt;Blog bodies translated fine. Titles and summaries sometimes didn't: a German or Arabic page went live with an English title.&lt;/p&gt;

&lt;p&gt;Our best explanation from the outputs: for some pairs, Turkish to German goes through English, and on short strings the second step sometimes doesn't happen. Language detection on a five-word Turkish title was also unreliable.&lt;/p&gt;

&lt;p&gt;What fixed it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Detect the source language once per post, &lt;strong&gt;from the body&lt;/strong&gt;, and pass it explicitly for every field.&lt;/li&gt;
&lt;li&gt;For short fields, try several paths in order (plain text, wrapped in a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, from the English translation with &lt;code&gt;source: 'en'&lt;/code&gt;, without name protection) and keep the first result that passes a language check.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The language check is cheap. For Arabic and Russian at least half the letters must be Arabic or Cyrillic. For German, Spanish, French and Azerbaijani the result must not be identical to the English translation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure 2: brand names got translated
&lt;/h2&gt;

&lt;p&gt;"OpenAI" became something like "open AI" spelled in Arabic letters. "Claude" and "Gemini" didn't fare much better.&lt;/p&gt;

&lt;p&gt;We now wrap a list of names in placeholders before sending text out and put them back afterwards. Placeholders get mangled sometimes too. When that happens we split the chunk at block boundaries and retry block by block. A block is accepted without protection only if every name from the source still appears in the output unchanged. If nothing works, only that block stays in Turkish.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure 3: half-translated pages were indexed
&lt;/h2&gt;

&lt;p&gt;This was the expensive one. When a placeholder broke, the old code kept the original Turkish chunk on purpose, which was safer than garbage. But the page still counted as "translated" and went into the sitemap. A sample check found Arabic, Russian and French pages with half-Turkish bodies, indexed as if they were translations.&lt;/p&gt;

&lt;p&gt;So every language version now has to pass a gate before it gets its own URL in the sitemap, &lt;code&gt;hreflang&lt;/code&gt; tags and &lt;code&gt;index&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isComplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;translated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// body must not shrink too much&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;plainText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;translated&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;plainText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;plainText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;translated&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;// too short to judge&lt;/span&gt;

  &lt;span class="c1"&gt;// too many common Turkish words: the body is still (partly) Turkish&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;turkish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;COMMON_TURKISH&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;turkish&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.02&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

  &lt;span class="c1"&gt;// Arabic and Russian: at least half the letters in the target script&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locale&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'ar'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;locale&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'ru'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;scriptRatio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;translated&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F73n8lcknb354e65365f1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F73n8lcknb354e65365f1.png" alt="Share of common Turkish words in translated bodies: clean pages 0 to 1.3%, broken ones 2.6% and up, gate at 2%" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 2% threshold came from live data. Clean pages scored at most 1.3%, the broken ones 2.6% and higher. When we shipped the gate, a bit under 600 blog language versions dropped out of the sitemap at once, and spot checks found no false alarms. A page that fails the gate still renders (Turkish with client-side translation), but it is &lt;code&gt;noindex&lt;/code&gt; and has no &lt;code&gt;hreflang&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure 4: CMS leftovers
&lt;/h2&gt;

&lt;p&gt;Posts migrated from WordPress still had block comments like &lt;code&gt;&amp;lt;!-- wp:paragraph --&amp;gt;&lt;/code&gt; in the HTML. The translation service treated them as text, and some pages showed "wp:paragrap h" in the body and the meta description. We now strip HTML comments before translating.&lt;/p&gt;

&lt;h2&gt;
  
  
  URLs per language
&lt;/h2&gt;

&lt;p&gt;Each blog post gets a slug in every language, generated from the translated title. Once written, the slug never changes, even if the title is edited later. Old or wrong-language slugs redirect with a 308.&lt;/p&gt;

&lt;p&gt;Generating slugs was its own small trap. Lowercasing with the locale's rules turned "AI" into "aı" in Azerbaijani, and "İ" into "i" plus a combining dot elsewhere. We now apply Turkish and Azerbaijani case rules only to words that contain letters specific to those languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is a better model worth paying for?
&lt;/h2&gt;

&lt;p&gt;That is the question we are testing now. Ten posts were retranslated into English and German with an LLM, with the same quality gate, for about $5.60 in total. Ten similar posts stayed on LibreTranslate as a control. We'll compare search clicks after five weeks. Ten against ten will only show a large difference, so the main thing we expect to learn is how the two read side by side.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we'd do again
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Store translations with a hash of the source, and delete them with a database trigger instead of application code.&lt;/li&gt;
&lt;li&gt;Assume a self-hosted model will fail silently, and decide what "complete" means before a page gets its own URL.&lt;/li&gt;
&lt;li&gt;Keep private messages out by constraint, not by convention.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have run a similar pipeline, especially for Arabic or Azerbaijani, I'd like to hear what your checks look like.&lt;/p&gt;

</description>
      <category>i18n</category>
      <category>nextjs</category>
      <category>seo</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
