Package: django-inlinetrans
IntroductionInlinetrans is a django application that allows the translation of django templates from the rendered html in the browser. Once you have your templates internationalized with inlinetrans, you can click on the untranslated messages in their corresponding web pages to add their translations. This can be of great help for translators, as they will be able to translate the messages right in their intended context.FeaturesA templatetag,inline_trans(oritrans), intended as a replacement for django’strans.A management command,inline_makemessage, intended as a replacement for django’smakemessages.A translation bar to show translatable messages, by default visible only tostaffmembers (you can change this behavior with the variable USER_CAN_TRANSLATE, add it in the settings)To translate the messages in a web page rendered in your browser, you first find out, through the translation bar, which messages have already been translated (marked light green) and which ones lack translation (marked light red).Then, you click on a marked message, and are prompted for its translation; on entering the text and clicking OK, the new translation is sent to the server and saved in the correct .po file.Once you have translated all messages in a page, you can click on “apply changes” on the translation bar. This forces a restart on the server, and the reloading of the page with the translations applied.RequirementsTo use inlinetrans, you need:Django>= 1.0jQuery>= 1.2.6Demo (this video use a very old version of django-inlinetrans)Video Demo, of django-inlinetrans,django-inplaceeditanddjango-inplaceedit-extra-fields(Set full screen mode to view it correctly)Using inlinetransMake sure you load inlinetrans in all templates you want to internationalize, by adding the following code:>>>
{% load inlinetrans %}
{% inlinetrans_static %}
<div id="inlinetrans-toolbar">place holder for inlinetrans toolbar</div>
{% inlinetrans_toolbar "inlinetrans-toolbar" %}Then, you can use:>>> {% inline_trans "translate this" %}Or:>>> {% itrans "translate this" %}Instead of:>>> {% trans "translate this" %}Also, you can customize the toolbar and other parameters using inlinetrans as follow:{% load i18n inlinetrans %}

{% inlinetrans_media %}

<script language="javascript">
    (function ($) {
        $(document).ready(function () {
            var messages_dict = {
                givetranslationfor: 'Give a new translation for {0} to {{ language }}',
                emptytranslation: "You're sending an empty translation ¿Are you sure? ",
                reloading: "Reloading",
                apply_changes: "Apply changes",
                applying_changes: "Applying changes",
                error_cant_send: "Can't send translation",
                error_cant_restart: "Can't restart server"
            };
            var new_translation_url = "{% url inlinetrans.views.set_new_translation %}";
            var restart_url = "{% url inlinetrans.views.do_restart %}";

            var toolbar_tpl = '\
                <div class="inlinetransContainer">\
                    <img id="changes-loading" src="{{ INLINETRANS_MEDIA_URL }}img/ajax-loader-transparent.gif"/>\
                    <span class="inlinetransActions">\
                        <span class="inlinetransAction hightlightTrans">See translatable items</span>\
                        <span class="inlinetransAction hightlightNotrans">See non translated items</span>\
                        <span class="inlinetransAction restartServer">Apply changes</span>\
                    </span>\
                </div>';
            // init inlinetrans toolbar
            $('#{{ node_id }}').inlinetranstoolbar(toolbar_tpl, new_translation_url, restart_url, messages_dict);
        });
    })(jQuery);
</script>Inlinetrans adds html code to each translation, so make sure you don’t useinline_transtags inside html attributes, such as this:>>> <a href="#" alt="{% inline_trans "translate this" %}"></a>In these cases you have to use the regulartranstag.Once your template is internationalized, you run the following command:>>> $ ./manage.py inline_makemessagesThis extracts bothinline_trans(itrans) andtransmessages from the templates, and incorporates them to the gettext catalogs, just as makemessages does fortransmessages.Afterwords, you can start your server, navigate to the rendered pages (by default, as a staff member), and, as explained above, translate the messages through the web.ContributorsAntonio Pérez-Aranda Alcaide, ant30Emilio Sánchez, emilio.sanchezManuel Saelices, linPablo Martín, goinnnChange history0.6.0 (2013-10-04)Support to python2.6 (It was not supported with django-inlinetrans==0.5.X)Improvements in the example project0.5.1 (2013-09-13)Improvements in metainfo (readme file, and contributors file)0.5.0 (2013-09-13)Django 1.5 (1.4, 1.3 and 1.2) compatible, before does not work because csrf token protectionPython 3 compatibleUse the statics file, django-inlinetrans used media files stillRemove polib frozen, now this is a dependenceRemove code of inline_makemessages, now fix the problem with monkey patchingNow we can customize with a setting that users can inline translateAdd example projectAdd meta info0.4.12 (2011-05-23)Drop line break from inlinetrans template0.4.11 (2011-05-17)Do not try to log server restarts if the log file doesn’t existFix double translation problem when template nodes are cached0.4.10 (2011-04-18)Django 1.3 compatibility0.4.9 (2011-04-13)Escape msgid so the DOM parser do not replace html entities. This fixes the translation of strings with entities like &copy;0.4.8 (2011-04-13)Send some data to avoid that a proxy/gateway/firewall blocks the POST request if it has no body.0.4.7 (2011-03-22)Set the locale path, needed if the django server has been launched from outside the project dir.0.4.6 (2011-03-18)Fixed translation when the label was found in two or more catalogs. The priority was not calculated well.0.4.5 (2011-03-17)Corrected command execution in some environments.0.4.4 (2011-03-17)Support for custom restart commands with parameters.0.4.3 (2011-03-14)Spanish translations.0.4.2 (2011-03-09)inline_makemessagescommand was not finding anyitranstemplatetag.0.4.1 (2011-02-27)Fixed a bug created in 0.4.0 for anonymous user.Make customizable the media base directory used by inlinetrans.0.4.0 (2011-02-24)Make compatible with Django 1.2 and 1.3.Allow using filters with the inline_trans tag.0.3.2 (2011-02-22)Allow to create/update po files when the msgid is not found in any catalog.0.3.1 (2011-02-08)Passed request to context because may be needed for external applications which customize templates.0.3 (2011-02-07)Refactored code to be more reusable and customizable from javascript. It’s now more like a jquery plugin.0.2 (2011-01-28)Created itrans templatetag, an alias for inline_trans.0.1 (2010-12-21)Adapting to use a egg using basic_package skelDownload