<?xml version="1.0" encoding="UTF-8" standalone="yes"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><id>https://blog.pgxn.org/tags/localization/</id><title>Localization</title><updated>2011-04-01T05:33:16Z</updated><link rel="self" type="application/atom+xml" href="https://blog.pgxn.org/tags/localization/feed.xml"/><link rel="alternate" type="text/html" href="https://blog.pgxn.org/tags/localization/"/><author><name>The PGXN Maintainers</name></author><generator uri="https://gohugo.io/" version="0.167.0">Hugo</generator><entry><id>https://blog.pgxn.org/post/4252690755</id><title type="html">Thoughts on Content Localization</title><link rel="alternate" type="text/html" href="https://blog.pgxn.org/2011/content-localization/"/><updated>2026-10-07T16:13:48Z</updated><published>2011-04-01T05:33:16Z</published><author><name>David E. Wheeler</name></author><category scheme="https://blog.pgxn.org/tags" term="localization" label="Localization"/><category scheme="https://blog.pgxn.org/tags" term="internationalization" label="Internationalization"/><category scheme="https://blog.pgxn.org/tags" term="translation" label="Translation"/><category scheme="https://blog.pgxn.org/tags" term="localemaketext" label="Locale::Maketext"/><summary type="html"><![CDATA[<p>The new site is coming along <em>very</em> nicely. I&rsquo;m really excited about it. The
addition of the API server has turned out to be an inspiration. I never
realized how clean the separation between content and presentation could be
until I did this &ndash; even though I&rsquo;ve preached that very separation for years
in one of my <a href="https://www.kineticode.com/">day jobs</a>.</p>
<p>But speaking of that separation, I am running into a bit of an annoyance with
content specific to the site. All the content from the network is working
beautifully &ndash; I just fetch it from the API server. But the site has its own
content page independent of the network, including an FAQ, a page on setting
up a mirror, a list of our backers, etc. And the ugly bit has to do with
localization.</p>]]></summary><content type="html" xml:base="https://blog.pgxn.org/" xml:space="preserve"><![CDATA[<p>The new site is coming along <em>very</em> nicely. I&rsquo;m really excited about it. The
addition of the API server has turned out to be an inspiration. I never
realized how clean the separation between content and presentation could be
until I did this &ndash; even though I&rsquo;ve preached that very separation for years
in one of my <a href="https://www.kineticode.com/">day jobs</a>.</p>
<p>But speaking of that separation, I am running into a bit of an annoyance with
content specific to the site. All the content from the network is working
beautifully &ndash; I just fetch it from the API server. But the site has its own
content page independent of the network, including an FAQ, a page on setting
up a mirror, a list of our backers, etc. And the ugly bit has to do with
localization.</p>
<p>I&rsquo;ve built the site (and <a href="https://manager.pgxn.org/">PGXN Manager</a>) using the Perl standard localization
library <a href="https://search.cpan.org/perldoc?Locale::Maketext">Locale::Maketext</a>. And it works great for short labels and such, like
so:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-perl" data-lang="perl"><span class="line"><span class="cl"><span class="k">our</span> <span class="nv">%Lexicon</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;hometitle&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;PGXN: PostgreSQL Extension Network&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;PostgreSQL Extension Network&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;PostgreSQL Extension Network&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;About PGXN&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;About PGXN&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;User&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;User&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;Recent Uploads&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;Recent Uploads&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;Blog&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;Blog&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;Frequently Asked Questions&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;Frequently Asked Questions&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="s">&#39;Release It&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;Release It&#39;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">);</span>
</span></span></code></pre></div><p>Translators just have to copy this code into a subclass and change the strings
on the right-hand side of the <code>=&gt;</code>s. Easy, right? It&rsquo;s also very good with
variables and pluralization. I just use it in the templates like this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-perl" data-lang="perl"><span class="line"><span class="cl"><span class="n">title</span> <span class="p">{</span> <span class="n">T</span> <span class="s">&#39;PostgreSQL Extension Network&#39;</span> <span class="p">};</span>
</span></span></code></pre></div><p>What sucks, however, is when I need to have longer content pages, especially
those that mix HTML in with the text. The FAQ is particularly relevant here:
most of the answers have at least one link embedded in them. The trouble is,
templating language encodes HTML entities. So I can&rsquo;t easily put HTML in the
localization files, unless I put it in raw, and the output it raw. So the
localization file might have a line like:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-perl" data-lang="perl"><span class="line"><span class="cl"><span class="s">&#39;Send us an &lt;a href=&#34;mailto:pgxn@example.com&#34;&gt;email&lt;/a&gt; with your questions&#39;</span> <span class="o">=&gt;</span>
</span></span><span class="line"><span class="cl"><span class="s">&#39;Send us an &lt;a href=&#34;mailto:pgxn@example.com&#34;&gt;email&lt;/a&gt; with your questions&#39;</span><span class="p">,</span>
</span></span></code></pre></div><p>And then the template would be told to output the text raw, without encoding
HTML entities:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-perl" data-lang="perl"><span class="line"><span class="cl"><span class="n">p</span> <span class="p">{</span> <span class="n">outs_raw</span> <span class="n">T</span> <span class="s">&#39;Send us an &lt;a href=&#34;mailto:pgxn@example.com&#34;&gt;email&lt;/a&gt; with your questions&#39;</span> <span class="p">};</span>
</span></span></code></pre></div><p>So now we&rsquo;ve lost the benefit of the templating, really: we have to write the
raw HTML ourselves. And besides, for multi-paragraph documents, it gets
annoying to have a bunch of localization lines with names like
<code>about_paragraph_1</code>, <code>about_paragraph_2</code>, etc. That makes it additionally
difficult for translators. There&rsquo;s just too much crap getting in the way. I&rsquo;ve
always liked the idea of having all translations in one place, but I don&rsquo;t
think there&rsquo;s enough of an advantage to that to overcome the annoyances.</p>
<p>So I&rsquo;d like to find a better way to manage these content pages more like
<em>documents,</em> in a format that&rsquo;s easy for translators to manage and isn&rsquo;t so
broken up. I&rsquo;m open to suggestions. Ideally the content would still be all
kept in one place for a given language, but maybe that&rsquo;s just not feasible.</p>
<p>The one thing that occurs to me is to keep documents for given languages in
separate <a href="https://daringfireball.net/projects/markdown/">Markdown</a>-formatted files. Each language would have a directory with
the language code (&ldquo;en&rdquo;, &ldquo;en-uk&rdquo;, &ldquo;fr&rdquo;, etc.), and then at build time they
would be converted to HTML for fast serving at run-time. Or maybe at
distribution-packaging time. I&rsquo;ve resisted something like this for a while
because it means one has to find stuff to translate in two different places
(the localization library for UI elements and the directory of documents for
content), but maybe it would be best.</p>
<p>How have you solved this problem in your apps? How badly have you annoyed your
translators?</p>
<p>Oh, while I&rsquo;m thinking about it, where should documentation for the API server
be published? I could include it in the <a href="https://github.com/theory/pgxn-api/">PGXN::API</a> source, which would be
useful for anyone else who wanted to run an API server (which will be dead
easy, by the way). But there will also be some stuff that&rsquo;s specific to a
given installation (proxying, downtime, etc.). So maybe it should go on the
main site or something? Or perhaps we need a dedicated wiki server for shit
like this (and some of those content pages like the FAQ, maybe).</p>
<p>Thoughts?</p>
]]></content></entry></feed>