This question has been flagged

I have this question opened here:

http://stackoverflow.com/questions/43892397/odoo-how-to-translate-strings-in-javascript-file


Copy/paste:

I'm struggling with the lack of understanding on doing Javascript. The Odoo documentation is painfully poor and I have another question on this topic without an answer here: http://stackoverflow.com/questions/42227474/odoo10-how-to-do-javascript

I hope I'll have more luck with this one.

What I'm trying to do now:

    var _t = null;
    odoo.define('mymodule.translate', function (require) {
    "use strict";
        var translation = require('web.translation');
        _t = translation._t;
        console.log("_t assigned");
    });

A view:

    app.categoriesView = Backbone.View.extend({
        tagName: 'div',
        className: 'categoriesView',
        template: _.template($('#categories_list_template').html()),
        initialize: function() {
            this.title = _t('OUR PRODUCTS');
            console.log("Initilized title: "+this.title);
        },
    });

Po file:

    #. module: mymodule
    #: code:addons/mymodule/static/js/views.js:8
    #, python-format
    msgid "OUR PRODUCTS"
    msgstr "PRODUKTI"

I don't get any errors and firebug console only says:

    _t assigned
    Initilized title: OUR PRODUCTS

So the string doesn't get translated. What am I doing wrong?




Avatar
Discard