djangosnippets.org: Latest snippets tagged with 'internationalization'http://djangosnippets.org/tags/internationalization/2016-11-16T22:32:54.999996-06:00Django 1.10 Internationalization Middleware
2016-11-16T22:32:54.999996-06:00agusmakmunhttp://djangosnippets.org/snippets/10594/<p>Django 1.10 Internationalization Middleware, more complete tutorial: https://python.web.id/blog/how-to-implement-django-internationalization/</p>
Freely redistributableautotranslate po files using microsoft translator
2012-02-08T00:11:53.115716-06:00prabhat246http://djangosnippets.org/snippets/2679/<p>This snippet is inspired by <a href="http://djangosnippets.org/snippets/1048/">dnordberg</a> 's translation script which used google's translation script. But after google translation is no more free. I put together it to use microsoft translator's python wrapper by <a href="https://github.com/openlabs/Microsoft-Translator-Python-API">openlab</a></p>
<h2>usage</h2>
<ol>
<li>
<p>get a bing appID from <a href="https://ssl.bing.com/webmaster/developers/appids.aspx">here</a> and replace it on the top of script</p>
</li>
<li>
<p>sudo …</p></li></ol>
Freely redistributableMultilingual site based on domain - not accept header and django_session
2012-01-07T16:36:32.827050-06:00hermanschttp://djangosnippets.org/snippets/2640/<p>On our site <a href="http://www.fornebuklinikken.no">Fornebuklinikken - A cosmetic surgeon in Norway</a> we also have a domain <a href="http://www.fornebuklinikken.no">http://fornebuklinikken.com</a> which should be using the 'en' language.</p>
<p>We didn't wan't to use the standard locale lib, and wrote our own middleware which lookups the correct language corresponding to the domain (.no or .com)</p>
<p>Any …</p>
Freely redistributableModeli18n
2010-06-08T10:16:13.332917-05:00pavlhttp://djangosnippets.org/snippets/2056/<p>This is a Model base class used to support internationalization (i18n) for your models. </p>
<p>This code extends the Django's Model class so you can use all available options from Model safely. Basicly, it uses introspection to create a sub-model to your model to hold translation.</p>
<p><strong>Features:</strong></p>
<ol>
<li>Simplicity of use. You …</li></ol>
Freely redistributableEnsure ugettext is available absolutely everywhere
2009-06-29T21:11:01.104813-05:00ElfSternberghttp://djangosnippets.org/snippets/1606/<p>Put this into the <strong>init.py</strong> file in the root of your project (the same directory level as urls.py and settings.py) and this installs _() as a global reference into the current running python VM, and now it’s as universally available as int(), map(), or str().</p>
<p>This is, of course, controversial. …</p>
Freely redistributableCurrency Field Admin Integration
2009-05-25T19:20:54.780882-05:00Rupehttp://djangosnippets.org/snippets/1529/<p>The BooleanField and DecimalField <code>elif</code> blocks are only included in this snippet to give context in the admin_list.py. Insert the CurrencyField block into the file and the Currency fields will display properly in record lists. If you have all of the objects ( <a href="http://www.djangosnippets.org/snippets/1525/">Currency Object</a>, <a href="http://www.djangosnippets.org/snippets/1526/">Currency Widget</a>, <a href="http://www.djangosnippets.org/snippets/1527/">Currency …</a></p>
Freely redistributableCurrency DB Field
2009-05-25T17:44:26.246403-05:00Rupehttp://djangosnippets.org/snippets/1528/<p>This is an extension of the DecimalField database field that uses my <a href="http://www.djangosnippets.org/snippets/1525/">Currency Object</a>, <a href="http://www.djangosnippets.org/snippets/1526/">Currency Widget</a>, and <a href="http://www.djangosnippets.org/snippets/1527/">Currency Form Field</a>. </p>
<p>I placed my Currency object in the Django\utils directory, the widget in Django\froms\widgets_special.py, and the form field in Django\forms\fields_special.py because I integrated this set of currency objects …</p>
Freely redistributableCurrency Form Field
2009-05-25T17:36:52.533635-05:00Rupehttp://djangosnippets.org/snippets/1527/<p>This is an extension of the DecimalField form field that uses my <a href="http://www.djangosnippets.org/snippets/1525/">Currency Object</a> and <a href="http://www.djangosnippets.org/snippets/1526/">Currency Widget</a>. </p>
<p>I placed my Currency object in the Django\utils directory and the widget in Django\froms\widgets_special.py because I integrated a set of currency objects into the Admin app ( <a href="http://www.djangosnippets.org/snippets/1529/">here</a> ) and it was …</p>
Freely redistributableCurrency Widget
2009-05-25T17:27:54.318429-05:00Rupehttp://djangosnippets.org/snippets/1526/<p>This is a simple TextInput widget that uses my <a href="http://www.djangosnippets.org/snippets/1525/">Currency object</a>. </p>
<p>I placed my Currency object in the Django utils directory because I integrated a set of currency objects into the Admin app ( <a href="http://www.djangosnippets.org/snippets/1529/">here</a> ) and it was just easier to have everything within Django.</p>
<p>The rest of …</p>
Freely redistributableCurrency Object
2009-05-25T16:55:42.533936-05:00Rupehttp://djangosnippets.org/snippets/1525/<p>This object stitches together the <a href="http://babel.edgewall.org/">Babel</a> number formating and the Decimal object, with a little of my own hand rolled validation for parsing. </p>
<p>Note the comment at the end of the code. It contains two lines to add to your settings.py.</p>
<pre><code>CURRENCY_LANGUAGE_CODE = 'pt_BR'
CURRENCY_CODE = '' # If one …</code></pre>
Freely redistributableTranslation statistics gatherer
2008-08-17T07:14:40.935872-05:00ramirohttp://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 redistributableLocalized URLs (www-en)
2007-02-25T14:04:28.465751-06:00zeeghttp://djangosnippets.org/snippets/5/<p>An example on how we changed our localization middleware to use www-en.<domain> instead of it being hidden in the cookie.</p>
<p>This also changes zh-cn to cn, and zh-tw to tw in the URLs.</p>
<p>This is only a base snippet and you will most likely need to modify it to fit …</p>
Freely redistributable