Django 1.2.3 - Internationalization - makemessages does not detect all lines

One more question about Django regarding localization of javascript files.

Django provides a small and handy javascript library that is used as gettext to internationalize strings in javascript files.

I installed it successfully (at least the interpolation function works) and I can generate a po file for the French language. However, not all rows are detected. I don’t know why, because they all look the same. I could not find anything on Django Trac and white papers.

The javascript code is in the external file included in the template, and Django apparently found it because it placed two lines in the po file.

Inclusion in the HTML template:

<script src="{{MEDIA_URL|default:'/media/'}}js/list.js" type="text/javascript"></script>

Javascript code:

/* ---------------
 * Upload progress
 * --------------- */
$(document).ready(function() {
    $(function() {
        $('#upload_form').uploadProgress({
            //...

            /* function called just before starting the upload */
            start: function() {
                $("#upload_form").hide();
                filename = $("#id_file").val().split(/[\/\\]/).pop();
                fmts = gettext('Uploading %(filename)s...');
                dat = {
                    filename: filename
                };
                s = interpolate(fmts,dat,true);
                $("#progress_filename").html(s);
                $("#progress_container").show();
            },

            /* function called each time bar is updated */
            uploading: function(upload) {
                if (upload.percents >= 100) {
                    window.clearTimeout(this.timer);
                    fmts = gettext("Saving %(filename)s...");
                    dat = {
                        filename: filename
                    };
                    s = interpolate(fmts,dat,true);
                    $("#progress_filename").html(s);
                } else {
                    fmts = gettext('Uploading %(filename)s : %(percents)s%...');
                    dat = {
                        filename: filename,
                        percents: upload.percents
                    };
                    s = interpolate(fmts,dat,true);
                    $("#progress_filename").html(s);
                }
            },

            //...

        });
    });
});


/* --------------------
 * Confirmation dialogs
 * -------------------- */
function delVid(title) {
    fmts = gettext('Do you really want to delete the video "%(title)s"?');
    dat = {
        title: title
    };
    s = interpolate(fmts,dat,true);
    return confirm(s)
}

function abortVid(title) {
    fmts = gettext('Do you really want to abort the processing of the video "%(title)s"?');
    dat = {
        title: title
    };
    s = interpolate(fmts,dat,true);
    return confirm(s)
}

- jquery.uploadprogress JQuery, - .

:

  • '% (filename) s...'
  • '% ( ) s...'

"django-admin.py -d djangojs -l fr", djangojs.po . . , . , .

?

+2
3

Jango Javascript . , . Django 1.3, Django ticket 7704. Django , , , ?:)

+1

, . - , "locale" . "my_project_root_dir" settings.INSTALLED_APPS, javascript.

, django makemessages , . mo , . , django makemessages , .

+1

The mechanism is different for javascript files. The translation is not generated in a regular po file, but in a javascript directory.

Have a look at this explanation in the Django book .

I hope this helps

0
source

All Articles