2
私はJavascriptを理解することに苦労しています。 Odooのドキュメントは苦しいものですが、私はここで答えなしでこのトピックについて別の質問をしています:Odoo10 - How to do javascriptOdoo - JavaScriptファイルで文字列を翻訳する方法
私はこれでもっと運がいいと思います。私は今、何をしようとしている
:
var _t = null;
odoo.define('mymodule.translate', function (require) {
"use strict";
var translation = require('web.translation');
_t = translation._t;
console.log("_t assigned");
});
ビュー:
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);
},
});
ポーファイル:
#. module: mymodule
#: code:addons/mymodule/static/js/views.js:8
#, python-format
msgid "OUR PRODUCTS"
msgstr "PRODUKTI"
私はすべてのエラーと放火魔コンソールを得ることはありませんのみと言う:
_t assigned
Initilized title: OUR PRODUCTS
したがって、文字列は翻訳されません。私は間違って何をしていますか?
あなたがにconsole.log(_T( "割り当てを"))を使用should'nt。 – Cherif
いいえ..このconsole.logはちょうどそこにありますので、 "odoo.define(" completed successfully。 – user568021
これをbackend_assetテンプレートに追加しましたか? – Cherif