Odoo Help

1

How to translate strings in javascript file

By
Prowler
on 5/10/17, 10:10 AM 1,216 views

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?




About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/10/17, 10:10 AM
Seen: 1216 times
Last updated: 7/22/18, 2:27 AM