djangosnippets.org: Latest snippets tagged with 'l10n'https://djangosnippets.org/tags/l10n/2008-08-17T07:14:40-05:00Translation statistics gatherer2008-08-17T07:14:40-05:00ramirohttps://djangosnippets.org/snippets/986/<p>A script that gathers statistics of translated, untranslated and fuzzy literals of translations (be it Django itself or a project using Django).</p>
<p>For that it re-scans the tree and generates a up-to-date POT in a temporary location, so the statistics of translation "coverage" are calculated relative to the current status ...</p>
Freely redistributableBabelMiddleware2007-07-16T09:32:54-05:00skamhttps://djangosnippets.org/snippets/320/<p>Originally posted on <a href="http://skam.webfactional.com/blog/2007/07/16/babel-integration-django/">skam.webfactional.com</a></p>
<p>This is a very simple middleware that uses babel (http://babel.edgewall.org) for accessing locale data in request objects through request.LOCALE attribute.</p>
<p>It also provides a function to get locale data outside views.</p>
<p>settings.py:</p>
<pre><code>MIDDLEWARE_CLASSES = (
... cut ...
'django.middleware.locale.LocaleMiddleware',
'middleware ...</code></pre>
Freely redistributableIgnore HTTP Accept-Language headers2007-05-07T10:10:40-05:00fonsohttps://djangosnippets.org/snippets/218/<p>A little tiny middleware that, when used in multilingual sites, will make Django I18N ignore any <code>Accept-Language</code> headers in the request, thus ensuring that every first-time visitor (with no explicit language preference set via session or cookie) will see the site in the language specified by <code>settings.LANGUAGE_CODE</code>. </p>
<p>(Please note ...</p>
Freely redistributableMultilingual Models2007-02-28T11:34:37-06:00Archatashttps://djangosnippets.org/snippets/51/<p>A way to implement models with translatable content.</p>
<p>The translatable field of the default language has no extension, like "title" and the translations have extensions postfixes "_&lt;two-letter language code&gt;", like "title_la" or "title_mn". Method get_title() in this case returns the translation of the currently chosen language or the title ...</p>
Freely redistributable