odoo.define('website.translateMenu', function (require) { 'use strict'; var utils = require('web.utils'); var TranslatorMenu = require('website.editor.menu.translate'); var websiteNavbarData = require('website.navbar'); var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ assetLibs: ['web_editor.compiled_assets_wysiwyg', 'website.compiled_assets_wysiwyg'], actions: _.extend({}, websiteNavbarData.WebsiteNavbar.prototype.actions || {}, { edit_master: '_goToMasterPage', translate: '_startTranslateMode', }), /** * @override */ start: function () { var context; this.trigger_up('context_get', { extra: true, callback: function (ctx) { context = ctx; }, }); this._mustEditTranslations = context.edit_translations; if (this._mustEditTranslations) { var url = window.location.href.replace(/([?&])&*edit_translations[^&#]*&?/, '\$1'); window.history.replaceState({}, null, url); this._startTranslateMode(); } return this._super.apply(this, arguments); }, //-------------------------------------------------------------------------- // Actions //-------------------------------------------------------------------------- /** * Redirects the user to the same page but in the original language and in * edit mode. * * @private * @returns {Promise} */ _goToMasterPage: function () { var current = document.createElement('a'); current.href = window.location.toString(); current.search += (current.search ? '&' : '?') + 'enable_editor=1'; // we are in translate mode, the pathname starts with '/