djangosnippets.org: Latest snippets tagged with 'i18n'http://djangosnippets.org/tags/i18n/2016-02-09T18:17:35.007222-06:00Django app/project/directory po messages collector and pofile bulder
2016-02-09T18:17:35.007222-06:00sakkadahttp://djangosnippets.org/snippets/10555/<p>Some times if third party application is not translated competelly, developer have to extract and save all of <strong>i18n</strong> strings of third party application to current project, somewhere in root project directory (and configure additional <code>LOCALE_DIRS</code> entry) or in any project's applications (usually named "main" or same as project).<br />
And …</p>
Freely redistributableLocaleMiddleware without browser language discovery
2015-02-26T14:20:52.602413-06:00ivellioshttp://djangosnippets.org/snippets/10469/<p>This snippet holds your Django project from automatically changing language of the page to the best fitting one by discovering the client browser language.</p>
<p>I personally needed to show the page to the user for the first time in the default language (English), although there were some translations. User can …</p>
Freely redistributableExtended i18n base model
2013-04-08T23:32:21.041419-05:00alcinnzhttp://djangosnippets.org/snippets/2907/<p>This snippet is an extension of <a href="http://djangosnippets.org/snippets/855/">i18n base model for translatable content</a> so all the same usage applies.</p>
<p>I have extended this module in several ways to make it more fully featured.</p>
<ul>
<li>
<p><code>I18NMixin</code> can be an additional (via multiple inheritance) or alternative superclass for your models juxtaposed with an <code>I18NModel …</code></p></li></ul>
Freely redistributableGet active page's url by another language (templatetag)
2013-01-06T10:28:40.947626-06:00muratcorluhttp://djangosnippets.org/snippets/2875/<p>Usage:</p>
<pre><code>{% load helper_tags %}
{% get_available_languages as languages %}
{% for lang_code, lang_name in languages %}
<link rel="alternate" hreflang="{{ lang_code }}" href="{% change_lang lang_code %}">
{% endfor %}
</code></pre>
Freely redistributableI18n Get all language models with form. Tüm diller için otomatik form
2012-06-25T04:01:22.307829-05:00musluhttp://djangosnippets.org/snippets/2780/<p>I18n Get all language with form.
Tüm diller için otomatik form</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 redistributableOther translation block
2011-05-02T03:41:25.283256-05:00cecedille1http://djangosnippets.org/snippets/2423/<p>Use in a with statement to set the translation to another locale for a block<br />
>>> from django.utils.translation import ugettext
>>> ugettext('title')
u'title'
>>> with Translation('fr') as locale:
...: print locale.locale
...: print ugettext('title')
...: <br />
...: <br />
fr
titre
>>> ugettext('title')
u'title'</p>
Freely redistributableHumanized and localized timesince template filter
2010-11-26T06:19:20.695704-06:00slinkhttp://djangosnippets.org/snippets/2275/<p>Humanized and localized version of built-in <em>timesince</em> template filter.</p>
<p>Based on <a href="http://www.joeyb.org/blog/2009/10/08/custom-django-template-filter-for-humanized-timesince">Joey Bratton's idea</a>.</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 redistributableAdmin Apps Names Translation
2010-01-22T09:14:33.127479-06:00Nadhttp://djangosnippets.org/snippets/1882/<p>This Snippet allows for your project's apps names to be displayed as you want in the Admin, including translations.</p>
<p>The lists of apps and languages are created from your settings.py file.</p>
<p><strong>How to use</strong></p>
<p>1st part:</p>
<ul>
<li>
<p>Create a application called 'apps_verbose' in you project with the models.py and admin.py showed …</p></li></ul>
Freely redistributablelanguage switcher in admin
2009-11-09T18:24:47.303492-06:00lawgonhttp://djangosnippets.org/snippets/1787/<p>you have a multilingual site and need to change languages in admin. Previously this was easy in the site itself and more difficult in admin. Now it is dead easy. Set up your languages in settings.py. Make a directory called 'admin' in your templates directory, copy ~/django/contrib/admin/templates/base.html to that directory. …</p>
Freely redistributableMiddleware to reload translation for each request
2009-08-28T04:02:03.813447-05:00asksolhttp://djangosnippets.org/snippets/1704/<p>This will reload the translation file for every request if you add it as a middleware in settings.MIDDLEWARE_CLASSES.</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 redistributable