diff --git a/addons/account/static/src/components/account_move_service/account_move_service.js b/addons/account/static/src/components/account_move_service/account_move_service.js index 99494fcab7c..aac36e55355 100644 --- a/addons/account/static/src/components/account_move_service/account_move_service.js +++ b/addons/account/static/src/components/account_move_service/account_move_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { escape } from "@web/core/utils/strings"; import { markup } from "@odoo/owl"; @@ -13,7 +14,7 @@ export const accountMove = { async addDeletionDialog(component, moveIds) { const isMoveEndOfChain = await orm.call('account.move', 'check_move_sequence_chain', [moveIds]); if (!isMoveEndOfChain) { - const message = env._t("This operation will create a gap in the sequence."); + const message = _t("This operation will create a gap in the sequence."); const confirmationDialogProps = component.deleteConfirmationDialogProps; confirmationDialogProps.body = markup(`
${escape(message)}
${escape(confirmationDialogProps.body)}`); dialog.add(ConfirmationDialog, confirmationDialogProps); diff --git a/addons/account/static/src/components/account_payment_field/account_payment_field.js b/addons/account/static/src/components/account_payment_field/account_payment_field.js index e130ae874c4..a38a11615aa 100644 --- a/addons/account/static/src/components/account_payment_field/account_payment_field.js +++ b/addons/account/static/src/components/account_payment_field/account_payment_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { usePopover } from "@web/core/popover/popover_hook"; import { useService } from "@web/core/utils/hooks"; @@ -53,7 +54,7 @@ export class AccountPaymentField extends Component { onInfoClick(ev, idx) { this.popover.open(ev.currentTarget, { - title: this.env._t("Journal Entry Info"), + title: _t("Journal Entry Info"), ...this.lines[idx], _onRemoveMoveReconcile: this.removeMoveReconcile.bind(this), _onOpenMove: this.openMove.bind(this), diff --git a/addons/account/static/src/components/account_type_selection/account_type_selection.js b/addons/account/static/src/components/account_type_selection/account_type_selection.js index a2b79d82c19..5b695790ca6 100644 --- a/addons/account/static/src/components/account_type_selection/account_type_selection.js +++ b/addons/account/static/src/components/account_type_selection/account_type_selection.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field"; @@ -7,14 +8,14 @@ export class AccountTypeSelection extends SelectionField { get hierarchyOptions() { const opts = this.options; return [ - { name: this.env._t('Balance Sheet') }, - { name: this.env._t('Assets'), children: opts.filter(x => x[0] && x[0].startsWith('asset')) }, - { name: this.env._t('Liabilities'), children: opts.filter(x => x[0] && x[0].startsWith('liability')) }, - { name: this.env._t('Equity'), children: opts.filter(x => x[0] && x[0].startsWith('equity')) }, - { name: this.env._t('Profit & Loss') }, - { name: this.env._t('Income'), children: opts.filter(x => x[0] && x[0].startsWith('income')) }, - { name: this.env._t('Expense'), children: opts.filter(x => x[0] && x[0].startsWith('expense')) }, - { name: this.env._t('Other'), children: opts.filter(x => x[0] && x[0] === 'off_balance') }, + { name: _t('Balance Sheet') }, + { name: _t('Assets'), children: opts.filter(x => x[0] && x[0].startsWith('asset')) }, + { name: _t('Liabilities'), children: opts.filter(x => x[0] && x[0].startsWith('liability')) }, + { name: _t('Equity'), children: opts.filter(x => x[0] && x[0].startsWith('equity')) }, + { name: _t('Profit & Loss') }, + { name: _t('Income'), children: opts.filter(x => x[0] && x[0].startsWith('income')) }, + { name: _t('Expense'), children: opts.filter(x => x[0] && x[0].startsWith('expense')) }, + { name: _t('Other'), children: opts.filter(x => x[0] && x[0] === 'off_balance') }, ]; } } diff --git a/addons/account/static/src/components/bills_upload/bills_upload.js b/addons/account/static/src/components/bills_upload/bills_upload.js index 31c99596653..9b7fd07fd3a 100644 --- a/addons/account/static/src/components/bills_upload/bills_upload.js +++ b/addons/account/static/src/components/bills_upload/bills_upload.js @@ -105,7 +105,7 @@ export class AccountDropZone extends Component { uploadInput.dispatchEvent(new Event("change")); } else { this.notificationService.add( - this.env._t("Could not upload files"), + _t("Could not upload files"), { type: "danger", }); diff --git a/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.js b/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.js index 4d88cd6be2b..586ac44e09a 100644 --- a/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.js +++ b/addons/account/static/src/components/journal_dashboard_activity/journal_dashboard_activity.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { standardFieldProps } from "@web/views/fields/standard_field_props"; @@ -27,7 +28,7 @@ export class JournalDashboardActivity extends Component { async openActivity(activity) { this.action.doAction({ type: 'ir.actions.act_window', - name: this.env._t('Journal Entry'), + name: _t('Journal Entry'), target: 'current', res_id: activity.res_id, res_model: 'account.move', @@ -38,7 +39,7 @@ export class JournalDashboardActivity extends Component { openAllActivities(e) { this.action.doAction({ type: 'ir.actions.act_window', - name: this.env._t('Journal Entries'), + name: _t('Journal Entries'), res_model: 'account.move', views: [[false, 'kanban'], [false, 'form']], search_view_id: [false], diff --git a/addons/account/static/src/components/mail_attachments/mail_attachments.js b/addons/account/static/src/components/mail_attachments/mail_attachments.js index 3e68a8f0111..2e845c1132a 100644 --- a/addons/account/static/src/components/mail_attachments/mail_attachments.js +++ b/addons/account/static/src/components/mail_attachments/mail_attachments.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { FileInput } from "@web/core/file_input/file_input"; @@ -37,7 +38,7 @@ export class MailAttachments extends Component { for (const file of files) { if (file.error) { return this.notification.add(file.error, { - title: this.env._t("Uploading error"), + title: _t("Uploading error"), type: "danger", }); } diff --git a/addons/account_peppol/static/src/components/res_config_settings_buttons/res_config_settings_buttons.js b/addons/account_peppol/static/src/components/res_config_settings_buttons/res_config_settings_buttons.js index 5c44af9cbcf..f956936ca3f 100644 --- a/addons/account_peppol/static/src/components/res_config_settings_buttons/res_config_settings_buttons.js +++ b/addons/account_peppol/static/src/components/res_config_settings_buttons/res_config_settings_buttons.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { escape } from "@web/core/utils/strings"; import { registry } from "@web/core/registry"; import { pick } from "@web/core/utils/objects"; @@ -55,8 +56,8 @@ class PeppolSettingsButtons extends Component { } showConfirmation(warning, methodName) { - const message = this.env._t(warning); - const confirmMessage = this.env._t("You will not be able to send or receive Peppol documents in Odoo anymore. Are you sure you want to proceed?"); + const message = _t(warning); + const confirmMessage = _t("You will not be able to send or receive Peppol documents in Odoo anymore. Are you sure you want to proceed?"); this.dialogService.add(ConfirmationDialog, { body: markup( `
${escape(message)}
@@ -90,7 +91,7 @@ class PeppolSettingsButtons extends Component { // changes on both the client side and the iap side need to be saved within one method await this._callConfigMethod("button_update_peppol_user_data", true); this.notification.add( - this.env._t("Contact details were updated."), + _t("Contact details were updated."), { type: "success" } ); } diff --git a/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js b/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js index af21cafd195..22a6077137b 100644 --- a/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js +++ b/addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js @@ -69,7 +69,7 @@ export class AnalyticDistribution extends Component { onClose: () => { this.mainRef.el.focus(); }, - fieldString: this.env._t("Analytic Distribution Template"), + fieldString: _t("Analytic Distribution Template"), }); this.allPlans = []; this.lastAccount = this.props.account_field && this.props.record.data[this.props.account_field] || false; @@ -202,7 +202,7 @@ export class AnalyticDistribution extends Component { optionsSourceAnalytic(groupId) { return { - placeholder: this.env._t("Loading..."), + placeholder: _t("Loading..."), options:(searchTerm) => this.loadOptionsSourceAnalytic(groupId, searchTerm), }; } @@ -249,7 +249,7 @@ export class AnalyticDistribution extends Component { if (records.length) { options.push({ - label: this.env._t("View all"), + label: _t("View all"), action: (editedTag) => this.onViewAll(searchTerm, editedTag), classList: "o_m2o_dropdown_option o_m2o_dropdown_option_view_all", }); @@ -257,7 +257,7 @@ export class AnalyticDistribution extends Component { else { options.push({ - label: this.env._t("No Analytic Accounts for this plan"), + label: _t("No Analytic Accounts for this plan"), classList: "o_m2o_no_result", unselectable: true, }); @@ -271,14 +271,14 @@ export class AnalyticDistribution extends Component { if (searchTerm.length) { dynamicFilters = [ { - description: this.env._t("Quick search: %s", searchTerm), + description: _t("Quick search: %s", searchTerm), domain: this.searchAnalyticDomain(searchTerm), }, ]; } this.selectCreateIsOpen = true; this.addDialog(SelectCreateDialog, { - title: this.env._t("Search: Analytic Account"), + title: _t("Search: Analytic Account"), noCreate: true, multiSelect: true, resModel: 'account.analytic.account', diff --git a/addons/auth_password_policy/static/src/password_meter.js b/addons/auth_password_policy/static/src/password_meter.js index 13e128a4f15..26de9d76db5 100644 --- a/addons/auth_password_policy/static/src/password_meter.js +++ b/addons/auth_password_policy/static/src/password_meter.js @@ -1,14 +1,15 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { computeScore } from "./password_policy"; const { Component, xml } = owl; export class Meter extends Component { get title() { - return this.env._t( + return _t( "Required: %s\n\nHint: to increase password strength, increase length, use multiple words, and use non-letter characters.", - String(this.props.required) || this.env._t("no requirements") + String(this.props.required) || _t("no requirements") ); } diff --git a/addons/barcodes/static/src/barcode_handlers.js b/addons/barcodes/static/src/barcode_handlers.js index 98b5f41cbf1..02f62178109 100644 --- a/addons/barcodes/static/src/barcode_handlers.js +++ b/addons/barcodes/static/src/barcode_handlers.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { getVisibleElements } from "@web/core/utils/ui"; import { MacroEngine } from "@web/core/macro"; @@ -78,8 +79,8 @@ export const barcodeGenericHandlers = { if (fn) { fn(); } else { - notification.add(env._t("Barcode: ") + `'${barcode}'`, { - title: env._t("Unknown barcode command"), + notification.add(_t("Barcode: ") + `'${barcode}'`, { + title: _t("Unknown barcode command"), type: "danger" }); } diff --git a/addons/barcodes/static/src/components/barcode_scanner.js b/addons/barcodes/static/src/components/barcode_scanner.js index acebb585da4..da765214bed 100644 --- a/addons/barcodes/static/src/components/barcode_scanner.js +++ b/addons/barcodes/static/src/components/barcode_scanner.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { isBarcodeScannerSupported, scanBarcode } from "@web/webclient/barcode/barcode_scanner"; import { Component } from "@odoo/owl"; import { useService } from "@web/core/utils/hooks"; @@ -29,7 +30,7 @@ export class BarcodeScanner extends Component { window.navigator.vibrate(100); } } else { - this.notification.add(error || this.env._t("Please, Scan again!"), { + this.notification.add(error || _t("Please, Scan again!"), { type: "warning", }); } diff --git a/addons/base_import/static/src/import_action/import_action.js b/addons/base_import/static/src/import_action/import_action.js index 599e35f44b9..d9bca2afc20 100644 --- a/addons/base_import/static/src/import_action/import_action.js +++ b/addons/base_import/static/src/import_action/import_action.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component, onWillStart, onMounted, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; @@ -26,7 +27,7 @@ export class ImportAction extends Component { this.router = useService("router"); this.user = useService("user"); - this.env.config.setDisplayName(this.props.action.name || this.env._t("Import a File")); + this.env.config.setDisplayName(this.props.action.name || _t("Import a File")); this.resModel = this.props.action.params.model; this.model = useImportModel({ env: this.env, @@ -124,7 +125,7 @@ export class ImportAction extends Component { this.state.filename = files[0].name; this.state.importMessages = []; - this.model.block(this.env._t("Loading file...")); + this.model.block(_t("Loading file...")); const { res, error } = await this.model.updateData(true); if (error) { @@ -137,7 +138,7 @@ export class ImportAction extends Component { } async handleImport(isTest = true) { - const message = isTest ? this.env._t("Testing") : this.env._t("Importing"); + const message = isTest ? _t("Testing") : _t("Importing"); let blockComponent; if (this.isBatched) { @@ -170,7 +171,7 @@ export class ImportAction extends Component { } if (!isTest && res.ids.length) { - this.notification.add(this.env._t("%s records successfully imported", res.ids.length), { + this.notification.add(_t("%s records successfully imported", res.ids.length), { type: "success", }); this.exit(); diff --git a/addons/board/static/src/add_to_board/add_to_board.js b/addons/board/static/src/add_to_board/add_to_board.js index f581b83ed0c..fb35cb5f8fc 100644 --- a/addons/board/static/src/add_to_board/add_to_board.js +++ b/addons/board/static/src/add_to_board/add_to_board.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { registry } from "@web/core/registry"; import { useAutofocus, useService } from "@web/core/utils/hooks"; @@ -35,12 +36,8 @@ export class AddToBoard extends Component { async addToBoard() { const { domain, globalContext } = this.env.searchModel; - const { - comparison, - context, - groupBys, - orderBy, - } = this.env.searchModel.getPreFavoriteValues(); + const { comparison, context, groupBys, orderBy } = + this.env.searchModel.getPreFavoriteValues(); const contextToSave = { ...globalContext, ...context, @@ -60,15 +57,15 @@ export class AddToBoard extends Component { if (result) { this.notification.add( - this.env._t("Please refresh your browser for the changes to take effect."), + _t("Please refresh your browser for the changes to take effect."), { - title: this.env._t("“%s” added to dashboard", this.state.name), + title: _t("“%s” added to dashboard", this.state.name), type: "warning", } ); this.state.name = this.env.config.getDisplayName(); } else { - this.notification.add(this.env._t("Could not add filter to dashboard"), { + this.notification.add(_t("Could not add filter to dashboard"), { type: "danger", }); } diff --git a/addons/board/static/src/board_controller.js b/addons/board/static/src/board_controller.js index 1fd4b9d2c9b..7af779e6022 100644 --- a/addons/board/static/src/board_controller.js +++ b/addons/board/static/src/board_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { Dropdown } from "@web/core/dropdown/dropdown"; @@ -92,7 +93,7 @@ export class BoardController extends Component { closeAction(column, action) { this.dialogService.add(ConfirmationDialog, { - body: this.env._t("Are you sure that you want to remove this item?"), + body: _t("Are you sure that you want to remove this item?"), confirm: () => { const index = column.actions.indexOf(action); column.actions.splice(index, 1); diff --git a/addons/bus/static/src/services/assets_watchdog_service.js b/addons/bus/static/src/services/assets_watchdog_service.js index 8ac2fda7152..8850006fbc5 100644 --- a/addons/bus/static/src/services/assets_watchdog_service.js +++ b/addons/bus/static/src/services/assets_watchdog_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; import { session } from "@web/session"; @@ -28,13 +29,13 @@ export const assetsWatchdogService = { // We wait until things settle down browser.clearTimeout(bundleNotifTimerID); bundleNotifTimerID = browser.setTimeout(() => { - notification.add(env._t("The page appears to be out of date."), { - title: env._t("Refresh"), + notification.add(_t("The page appears to be out of date."), { + title: _t("Refresh"), type: "warning", sticky: true, buttons: [ { - name: env._t("Refresh"), + name: _t("Refresh"), primary: true, onClick: () => { browser.location.reload(); diff --git a/addons/calendar/static/src/js/services/calendar_notification_service.js b/addons/calendar/static/src/js/services/calendar_notification_service.js index 11594cf4aa6..f45a762dc00 100644 --- a/addons/calendar/static/src/js/services/calendar_notification_service.js +++ b/addons/calendar/static/src/js/services/calendar_notification_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { ConnectionLostError } from "@web/core/network/rpc_service"; import { registry } from "@web/core/registry"; @@ -44,7 +45,7 @@ export const calendarNotificationService = { }, buttons: [ { - name: env._t("OK"), + name: _t("OK"), primary: true, onClick: async () => { await rpc("/calendar/notify_ack"); @@ -52,7 +53,7 @@ export const calendarNotificationService = { }, }, { - name: env._t("Details"), + name: _t("Details"), onClick: async () => { await action.doAction({ type: 'ir.actions.act_window', @@ -65,7 +66,7 @@ export const calendarNotificationService = { }, }, { - name: env._t("Snooze"), + name: _t("Snooze"), onClick: () => { notificationRemove(); }, diff --git a/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.js b/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.js index 333f1e60522..62ec5d94911 100644 --- a/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.js +++ b/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dialog } from "@web/core/dialog/dialog"; const { Component } = owl; @@ -9,15 +10,15 @@ export class AskRecurrenceUpdatePolicyDialog extends Component { this.possibleValues = { self_only: { checked: true, - label: this.env._t("This event"), + label: _t("This event"), }, future_events: { checked: false, - label: this.env._t("This and following events"), + label: _t("This and following events"), }, all_events: { checked: false, - label: this.env._t("All events"), + label: _t("All events"), }, }; } diff --git a/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.xml b/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.xml index 43ef8a36677..8f6c3671ba0 100644 --- a/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.xml +++ b/addons/calendar/static/src/views/ask_recurrence_update_policy_dialog.xml @@ -1,7 +1,8 @@ - + Edit Recurrent event + diff --git a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.js b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.js index 83cc27b5970..640e9e07442 100644 --- a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.js +++ b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarController } from "@web/views/calendar/calendar_controller"; import { useService } from "@web/core/utils/hooks"; import { onWillStart } from "@odoo/owl"; @@ -101,7 +102,7 @@ export class AttendeeCalendarController extends CalendarController { configureCalendarProviderSync(providerName) { this.actionService.doAction({ - name: this.env._t('Connect your Calendar'), + name: _t('Connect your Calendar'), type: 'ir.actions.act_window', res_model: 'calendar.provider.config', views: [[false, "form"]], diff --git a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_model.js b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_model.js index e4b1b3ef233..ad5c10efab3 100644 --- a/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_model.js +++ b/addons/calendar/static/src/views/attendee_calendar/attendee_calendar_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarModel } from "@web/views/calendar/calendar_model"; import { askRecurrenceUpdatePolicy } from "@calendar/views/ask_recurrence_update_policy_hook"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; @@ -141,7 +142,7 @@ export class AttendeeCalendarModel extends CalendarModel { } else { const confirm = await new Promise((resolve) => { this.dialog.add(ConfirmationDialog, { - body: this.env._t("Are you sure you want to delete this record?"), + body: _t("Are you sure you want to delete this record?"), confirm: resolve.bind(null, true), }, { onClose: resolve.bind(null, false), diff --git a/addons/fleet/static/src/js/fleet_form.js b/addons/fleet/static/src/js/fleet_form.js index 50808f6b2e8..70105e9553f 100644 --- a/addons/fleet/static/src/js/fleet_form.js +++ b/addons/fleet/static/src/js/fleet_form.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { registry } from "@web/core/registry"; import { FormController } from "@web/views/form/form_controller"; @@ -13,7 +14,7 @@ export class FleetFormController extends FormController { const menuItems = super.getStaticActionMenuItems(); menuItems.archive.callback = () => { const dialogProps = { - body: this.env._t( + body: _t( "Every service and contract of this vehicle will be considered as archived. Are you sure that you want to archive this record?" ), confirm: () => this.model.root.archive(), diff --git a/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js b/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js index 7194b8479ad..4825f8b5096 100644 --- a/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js +++ b/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller"; import { patch } from "@web/core/utils/patch"; import { useService } from "@web/core/utils/hooks"; @@ -24,14 +25,14 @@ patch(AttendeeCalendarController.prototype, { } else if (syncResult.status === "need_config_from_admin") { if (this.isSystemUser) { this.dialog.add(ConfirmationDialog, { - title: this.env._t("Configuration"), - body: this.env._t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"), + title: _t("Configuration"), + body: _t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"), confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), }); } else { this.dialog.add(AlertDialog, { - title: this.env._t("Configuration"), - body: this.env._t("An administrator needs to configure Google Synchronization before you can use it!"), + title: _t("Configuration"), + body: _t("An administrator needs to configure Google Synchronization before you can use it!"), }); } } else if (syncResult.status === "need_refresh") { @@ -41,7 +42,7 @@ patch(AttendeeCalendarController.prototype, { async onStopGoogleSynchronization() { this.dialog.add(ConfirmationDialog, { - body: this.env._t("You are about to stop the synchronization of your calendar with Google. Are you sure you want to continue?"), + body: _t("You are about to stop the synchronization of your calendar with Google. Are you sure you want to continue?"), confirm: async () => { await this.orm.call( "res.users", @@ -49,9 +50,9 @@ patch(AttendeeCalendarController.prototype, { [[this.user.userId]], ); this.notification.add( - this.env._t("The synchronization with Google calendar was successfully stopped."), + _t("The synchronization with Google calendar was successfully stopped."), { - title: this.env._t("Success"), + title: _t("Success"), type: "success", }, ); diff --git a/addons/hr/static/src/user_menu/my_profile.js b/addons/hr/static/src/user_menu/my_profile.js index 3569b9dea9e..f425bbf8f4d 100644 --- a/addons/hr/static/src/user_menu/my_profile.js +++ b/addons/hr/static/src/user_menu/my_profile.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { preferencesItem } from "@web/webclient/user_menu/user_menu_items"; @@ -8,7 +9,7 @@ export function hrPreferencesItem(env) { {}, preferencesItem(env), { - description: env._t('My Profile'), + description: _t('My Profile'), } ); } diff --git a/addons/hr/static/src/views/archive_employee_hook.js b/addons/hr/static/src/views/archive_employee_hook.js index e36e02538fa..03ad7040a3e 100644 --- a/addons/hr/static/src/views/archive_employee_hook.js +++ b/addons/hr/static/src/views/archive_employee_hook.js @@ -1,17 +1,17 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; -const { useComponent, useEnv } = owl; +const { useComponent } = owl; export function useArchiveEmployee() { const component = useComponent(); - const env = useEnv(); const action = useService("action"); return (id) => { action.doAction({ type: 'ir.actions.act_window', - name: env._t('Employee Termination'), + name: _t('Employee Termination'), res_model: 'hr.departure.wizard', views: [[false, 'form']], view_mode: 'form', diff --git a/addons/hr_attendance/static/src/client_action/greeting_message/greeting_message.js b/addons/hr_attendance/static/src/client_action/greeting_message/greeting_message.js index 60703fffcf8..30f321719c5 100644 --- a/addons/hr_attendance/static/src/client_action/greeting_message/greeting_message.js +++ b/addons/hr_attendance/static/src/client_action/greeting_message/greeting_message.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CardLayout } from "@hr_attendance/components/card_layout/card_layout"; import { Component, onWillStart, onWillUnmount, useState } from "@odoo/owl"; import { deserializeDateTime } from "@web/core/l10n/dates"; @@ -72,7 +73,7 @@ export class GreetingMessage extends Component { .toFormat("hh-mm") .split("-"); - this.hours_today = this.env._t("%(hours)s hours, %(minutes)s minutes", { + this.hours_today = _t("%(hours)s hours, %(minutes)s minutes", { hours: duration[0], minutes: duration[1], }); @@ -133,7 +134,6 @@ export class GreetingMessage extends Component { } setWelcomeMessage() { - const { _t } = this.env; const now = this.attendance.check_in; if (now.hour < 5) { this.state.message = _t("Good night"); @@ -169,7 +169,6 @@ export class GreetingMessage extends Component { } setFarewellMessage() { - const { _t } = this.env; const now = this.attendance.check_out; if (this.previous_attendance_change_date) { diff --git a/addons/hr_expense/static/src/mixins/document_upload.js b/addons/hr_expense/static/src/mixins/document_upload.js index aa0be016e3f..83fa6ab22e3 100644 --- a/addons/hr_expense/static/src/mixins/document_upload.js +++ b/addons/hr_expense/static/src/mixins/document_upload.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useBus, useService } from '@web/core/utils/hooks'; const { useRef, useEffect, useState } = owl; @@ -93,7 +94,7 @@ export const ExpenseDocumentUpload = (T) => class ExpenseDocumentUpload extends const attachmentIds = attachments.map((a) => a.id); if (!attachmentIds.length) { this.notification.add( - this.env._t('An error occurred during the upload') + _t('An error occurred during the upload') ); return; } diff --git a/addons/hr_expense/static/src/mixins/qrcode.js b/addons/hr_expense/static/src/mixins/qrcode.js index 6c398ed9fc4..48557c203dc 100644 --- a/addons/hr_expense/static/src/mixins/qrcode.js +++ b/addons/hr_expense/static/src/mixins/qrcode.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; const { onMounted, onPatched, useRef } = owl; @@ -33,7 +34,7 @@ export const ExpenseMobileQRCode = (T) => class ExpenseMobileQRCode extends T { const url = ev.currentTarget && ev.currentTarget.href; if (!this.env.isSmall) { this.actionService.doAction({ - name: this.env._t("Download our App"), + name: _t("Download our App"), type: "ir.actions.client", tag: 'expense_qr_code_modal', target: "new", diff --git a/addons/hr_expense/static/src/views/expense_form_view.js b/addons/hr_expense/static/src/views/expense_form_view.js index ab20202353a..a5d656ef0d1 100644 --- a/addons/hr_expense/static/src/views/expense_form_view.js +++ b/addons/hr_expense/static/src/views/expense_form_view.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { registry } from "@web/core/registry"; import { FormController } from "@web/views/form/form_controller"; @@ -25,7 +26,7 @@ export class ExpenseFormController extends FormController { ) { return new Promise((resolve) => { this.dialogService.add(ConfirmationDialog, { - body: this.env._t("An expense of same category, amount and date already exists."), + body: _t("An expense of same category, amount and date already exists."), confirm: async () => { await this.orm.call("hr.expense", "action_approve_duplicates", [record.resId]); resolve(true); diff --git a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js index 2baefb26bcf..ab73f35a2cb 100644 --- a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js +++ b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { CalendarController } from '@web/views/calendar/calendar_controller'; import { FormViewDialog } from '@web/views/view_dialogs/form_view_dialog'; @@ -49,7 +50,7 @@ export class TimeOffCalendarController extends CalendarController { this.displayDialog(FormViewDialog, { resModel: 'hr.leave', - title: this.env._t('New Time Off'), + title: _t('New Time Off'), viewId: this.model.formViewId, onRecordSaved: () => { this.model.load(); @@ -71,7 +72,7 @@ export class TimeOffCalendarController extends CalendarController { this.displayDialog(FormViewDialog, { resModel: 'hr.leave.allocation', - title: this.env._t('New Allocation'), + title: _t('New Allocation'), context: context, }); } @@ -79,8 +80,8 @@ export class TimeOffCalendarController extends CalendarController { deleteRecord(record) { if (!record.can_cancel) { this.displayDialog(ConfirmationDialog, { - title: this.env._t("Confirmation"), - body: this.env._t("Are you sure you want to delete this record?"), + title: _t("Confirmation"), + body: _t("Are you sure you want to delete this record?"), confirm: async () => { await this.model.unlinkRecord(record.id); this.env.timeOffBus.trigger('update_dashboard'); diff --git a/addons/hr_holidays/static/src/views/calendar/year/calendar_year_renderer.js b/addons/hr_holidays/static/src/views/calendar/year/calendar_year_renderer.js index 7a4ead2aeac..65b6d5b2105 100644 --- a/addons/hr_holidays/static/src/views/calendar/year/calendar_year_renderer.js +++ b/addons/hr_holidays/static/src/views/calendar/year/calendar_year_renderer.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarYearRenderer } from '@web/views/calendar/calendar_year/calendar_year_renderer'; import { useService } from "@web/core/utils/hooks"; @@ -35,7 +36,7 @@ export class TimeOffCalendarYearRenderer extends CalendarYearRenderer { return Object.assign(super.options, { weekNumbers: true, weekNumbersWithinDays: false, - weekLabel: this.env._t('Week'), + weekLabel: _t('Week'), }); } diff --git a/addons/hr_holidays/static/src/views/hooks.js b/addons/hr_holidays/static/src/views/hooks.js index 2ee275137b5..c9c19d23a8c 100644 --- a/addons/hr_holidays/static/src/views/hooks.js +++ b/addons/hr_holidays/static/src/views/hooks.js @@ -1,9 +1,8 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; -const { useEnv } = owl; - export function useMandatoryDays(props) { return (info) => { const date = luxon.DateTime.fromJSDate(info.date).toISODate(); @@ -24,11 +23,10 @@ export function useMandatoryDays(props) { export function useLeaveCancelWizard() { const action = useService('action'); - const env = useEnv(); return (leaveId, callback) => { action.doAction({ - name: env._t('Delete Confirmation'), + name: _t('Delete Confirmation'), type: "ir.actions.act_window", res_model: "hr.holidays.cancel.leave", target: "new", diff --git a/addons/hr_homeworking/static/src/calendar/hr_homeworking_calendar_controller.js b/addons/hr_homeworking/static/src/calendar/hr_homeworking_calendar_controller.js index d3b4b3ae7b8..0d5e255c999 100644 --- a/addons/hr_homeworking/static/src/calendar/hr_homeworking_calendar_controller.js +++ b/addons/hr_homeworking/static/src/calendar/hr_homeworking_calendar_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { patch } from "@web/core/utils/patch"; import { useService } from "@web/core/utils/hooks"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; @@ -14,7 +15,7 @@ patch(AttendeeCalendarController.prototype, { async editRecord(record, context = {}, shouldFetchFormViewId = true) { if ('rawRecord' in record && 'date' in record.rawRecord) { return this.action.doAction('hr_homeworking.hr_employee_location_action',{ - name: this.env._t("Edit Record"), + name: _t("Edit Record"), additionalContext: { 'default_start_date': serializeDate(record.start), 'default_end_date_create': serializeDate(record.end), @@ -31,7 +32,7 @@ patch(AttendeeCalendarController.prototype, { createRecord(record) { if (record.homework) { return this.action.doAction('hr_homeworking.hr_employee_location_action',{ - name: this.env._t("Create Record"), + name: _t("Create Record"), additionalContext: { 'default_start_date': serializeDate(record.start), 'default_end_date_create': serializeDate(record.start), @@ -51,8 +52,8 @@ patch(AttendeeCalendarController.prototype, { this.openRecurringDeletionWizardForHomework(record); } else { this.displayDialog(ConfirmationDialog, { - title: this.env._t("Confirmation"), - body: this.env._t("Are you sure you want to delete this work location?"), + title: _t("Confirmation"), + body: _t("Are you sure you want to delete this work location?"), confirm: () => { this.orm.call('hr.employee.location', "unlink", [ record.rawRecord.idInDB, diff --git a/addons/hr_org_chart/static/src/fields/hooks.js b/addons/hr_org_chart/static/src/fields/hooks.js index ee771bcf98e..044ceccfdcc 100644 --- a/addons/hr_org_chart/static/src/fields/hooks.js +++ b/addons/hr_org_chart/static/src/fields/hooks.js @@ -1,8 +1,8 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import session from 'web.session' import { useService } from "@web/core/utils/hooks"; -import { useEnv } from "@odoo/owl"; /** * Redirect to the sub employee kanban view. @@ -16,7 +16,6 @@ export function onEmployeeSubRedirect() { const actionService = useService('action'); const orm = useService('orm'); const rpc = useService('rpc'); - const env = useEnv(); return async (event) => { const employeeId = parseInt(event.currentTarget.dataset.employeeId); @@ -32,7 +31,7 @@ export function onEmployeeSubRedirect() { }); let action = await orm.call('hr.employee', 'get_formview_action', [employeeId]); action = {...action, - name: env._t('Team'), + name: _t('Team'), view_mode: 'kanban,list,form', views: [[false, 'kanban'], [false, 'list'], [false, 'form']], domain: [['id', 'in', subordinateIds]], diff --git a/addons/hr_skills/static/src/views/skills_list_renderer.js b/addons/hr_skills/static/src/views/skills_list_renderer.js index d04b202cd22..f8feda14a27 100644 --- a/addons/hr_skills/static/src/views/skills_list_renderer.js +++ b/addons/hr_skills/static/src/views/skills_list_renderer.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ListRenderer } from "@web/views/list/list_renderer"; export class CommonSkillsListRenderer extends ListRenderer { @@ -26,7 +27,7 @@ export class CommonSkillsListRenderer extends ListRenderer { if (grouped[group[1]] === undefined) { grouped[group[1]] = { id: parseInt(group[0]), - name: group[1] || this.env._t('Other'), + name: group[1] || _t('Other'), list: { records: [], }, diff --git a/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar_model.js b/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar_model.js index 17587d58c2d..496c0d00a00 100644 --- a/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar_model.js +++ b/addons/hr_work_entry_contract/static/src/views/work_entry_calendar/work_entry_calendar_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarModel } from "@web/views/calendar/calendar_model"; import { useWorkEntry } from "@hr_work_entry_contract/views/work_entry_hook"; @@ -22,7 +23,7 @@ export class WorkEntryCalendarModel extends CalendarModel { makeFilterAll() { return { ...super.makeFilterAll(...arguments), - label: this.env._t("Everybody's work entries"), + label: _t("Everybody's work entries"), active: true, }; } diff --git a/addons/iap/static/src/js/insufficient_credit_error_handler.js b/addons/iap/static/src/js/insufficient_credit_error_handler.js index eb3d0e41b71..8a58e776507 100644 --- a/addons/iap/static/src/js/insufficient_credit_error_handler.js +++ b/addons/iap/static/src/js/insufficient_credit_error_handler.js @@ -2,6 +2,7 @@ import { Dialog } from "@web/core/dialog/dialog"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; +import { _t } from "@web/core/l10n/translation"; const { Component, onWillStart } = owl; @@ -20,7 +21,6 @@ class InsufficientCreditDialog extends Component { trial: errorData.trial, }); this.style = errorData.body ? "padding:0;" : ""; - const { _t } = this.env; const { isEnterprise } = odoo.info; if (errorData.trial && isEnterprise) { this.buttonMessage = _t("Start a Trial at Odoo"); diff --git a/addons/im_livechat/static/src/embed/frontend/boot_service.js b/addons/im_livechat/static/src/embed/frontend/boot_service.js index 80e4c56d2c1..34e2f59709d 100644 --- a/addons/im_livechat/static/src/embed/frontend/boot_service.js +++ b/addons/im_livechat/static/src/embed/frontend/boot_service.js @@ -3,7 +3,7 @@ import { makeRoot, makeShadow } from "@im_livechat/embed/boot_helpers"; import { LivechatRoot } from "@im_livechat/embed/frontend/livechat_root"; import { serverUrl, isAvailable } from "@im_livechat/embed/livechat_data"; - +import { _t } from "@web/core/l10n/translation"; import { App } from "@odoo/owl"; import { templates } from "@web/core/assets"; @@ -34,7 +34,7 @@ export const livechatBootService = { env, templates, translatableAttributes: ["data-tooltip"], - translateFn: env._t, + translateFn: _t, dev: env.debug, }).mount(shadow); }); diff --git a/addons/l10n_eg_edi_eta/static/src/client_action/sign_invoice.js b/addons/l10n_eg_edi_eta/static/src/client_action/sign_invoice.js index ebd55b5a5b8..8a252ef8f7f 100644 --- a/addons/l10n_eg_edi_eta/static/src/client_action/sign_invoice.js +++ b/addons/l10n_eg_edi_eta/static/src/client_action/sign_invoice.js @@ -2,11 +2,11 @@ import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { registry } from "@web/core/registry"; +import { _t } from "@web/core/l10n/translation"; async function actionGetDrive(env, action, type) { const { drive_id, sign_host: host } = action.params; const { orm, http, dialog, action: actionService } = env.services; - const { _t } = env; let route = host; let key, method; diff --git a/addons/lunch/static/src/mixins/lunch_renderer_mixin.js b/addons/lunch/static/src/mixins/lunch_renderer_mixin.js index dee5d86372e..f9f512b72b5 100644 --- a/addons/lunch/static/src/mixins/lunch_renderer_mixin.js +++ b/addons/lunch/static/src/mixins/lunch_renderer_mixin.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useBus, useService } from "@web/core/utils/hooks"; export const LunchRendererMixin = (T) => class LunchRendererMixin extends T { @@ -19,7 +20,7 @@ export const LunchRendererMixin = (T) => class LunchRendererMixin extends T { let action = { res_model: 'lunch.order', - name: this.env._t('Configure Your Order'), + name: _t('Configure Your Order'), type: 'ir.actions.act_window', views: [[false, 'form']], target: 'new', diff --git a/addons/mail/static/src/core/common/composer.js b/addons/mail/static/src/core/common/composer.js index fac5be3a908..76afb4d11af 100644 --- a/addons/mail/static/src/core/common/composer.js +++ b/addons/mail/static/src/core/common/composer.js @@ -511,10 +511,9 @@ export class Composer extends Component { this.state.active = true; el.focus(); } else if (attachments.some(({ uploading }) => Boolean(uploading))) { - this.env.services.notification.add( - this.env._t("Please wait while the file is uploading."), - { type: "warning" } - ); + this.env.services.notification.add(_t("Please wait while the file is uploading."), { + type: "warning", + }); } } diff --git a/addons/mail/static/src/js/tools/debug_manager.js b/addons/mail/static/src/js/tools/debug_manager.js index 4cc2dc22959..b8bdee4bfc7 100644 --- a/addons/mail/static/src/js/tools/debug_manager.js +++ b/addons/mail/static/src/js/tools/debug_manager.js @@ -1,5 +1,6 @@ -/* @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; export function manageMessages({ component, env }) { @@ -7,7 +8,7 @@ export function manageMessages({ component, env }) { if (!resId) { return null; // No record } - const description = env._t("Manage Messages"); + const description = _t("Manage Messages"); return { type: "item", description, diff --git a/addons/mail/static/src/views/web/activity/activity_controller.js b/addons/mail/static/src/views/web/activity/activity_controller.js index 29177767d9d..70c95417ade 100644 --- a/addons/mail/static/src/views/web/activity/activity_controller.js +++ b/addons/mail/static/src/views/web/activity/activity_controller.js @@ -1,5 +1,6 @@ -/* @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useMessaging } from "@mail/core/common/messaging_hook"; import { Component, useState } from "@odoo/owl"; @@ -47,7 +48,7 @@ export class ActivityController extends Component { resModel: this.props.resModel, searchViewId: this.env.searchModel.searchViewId, domain: this.model.originalDomain, - title: this.env._t("Search: %s", this.props.archInfo.title), + title: _t("Search: %s", this.props.archInfo.title), multiSelect: false, context: this.props.context, onSelected: async (resIds) => { diff --git a/addons/mass_mailing/static/src/js/mailing_m2o_filter.js b/addons/mass_mailing/static/src/js/mailing_m2o_filter.js index 9b7dfc9ea09..a93d63bd2ed 100644 --- a/addons/mass_mailing/static/src/js/mailing_m2o_filter.js +++ b/addons/mass_mailing/static/src/js/mailing_m2o_filter.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Domain } from '@web/core/domain'; import { registry } from '@web/core/registry'; import { Dropdown } from "@web/core/dropdown/dropdown"; @@ -132,7 +133,7 @@ export class FieldMany2OneMailingFilter extends Many2OneField { const filterName = filterInput.value.trim(); if (filterName.length === 0) { this.notification.add( - this.env._t("Please provide a name for the filter"), + _t("Please provide a name for the filter"), {type: 'danger'} ); // Keep the drop-down open, and re-focus the input diff --git a/addons/mass_mailing/static/src/js/mass_mailing_html_field.js b/addons/mass_mailing/static/src/js/mass_mailing_html_field.js index 81913b00949..a6f7213d5a4 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_html_field.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_html_field.js @@ -274,7 +274,7 @@ export class MassMailingHtmlField extends HtmlField { el.style.setProperty('pointer-events', 'none'); }); this.mobilePreview = this.dialog.add(MassMailingMobilePreviewDialog, { - title: this.env._t("Mobile Preview"), + title: _t("Mobile Preview"), preview: mailingHtml.body.innerHTML, }, { onClose: () => $previewBtn.prop('disabled', false), @@ -382,7 +382,7 @@ export class MassMailingHtmlField extends HtmlField { const $editable = this.wysiwyg.$editable.find('.o_editable'); this.$editorMessageElements = $editable .not('[data-editor-message]') - .attr('data-editor-message', this.env._t('DRAG BUILDING BLOCKS HERE')); + .attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE')); $editable.filter(':empty').attr('contenteditable', false); // Wait the next tick because some mutation have to be processed by diff --git a/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js b/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js index 746b663e789..29992f5dc88 100644 --- a/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js +++ b/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller"; import { patch } from "@web/core/utils/patch"; import { useService } from "@web/core/utils/hooks"; @@ -24,14 +25,14 @@ patch(AttendeeCalendarController.prototype, { } else if (syncResult.status === "need_config_from_admin") { if (this.isSystemUser) { this.dialog.add(ConfirmationDialog, { - title: this.env._t("Configuration"), - body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), + title: _t("Configuration"), + body: _t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), }); } else { this.dialog.add(AlertDialog, { - title: this.env._t("Configuration"), - body: this.env._t("An administrator needs to configure Outlook Synchronization before you can use it!"), + title: _t("Configuration"), + body: _t("An administrator needs to configure Outlook Synchronization before you can use it!"), }); } } else if (syncResult.status === "need_refresh") { @@ -41,7 +42,7 @@ patch(AttendeeCalendarController.prototype, { async onStopMicrosoftSynchronization() { this.dialog.add(ConfirmationDialog, { - body: this.env._t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"), + body: _t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"), confirm: async () => { await this.orm.call( "res.users", @@ -49,9 +50,9 @@ patch(AttendeeCalendarController.prototype, { [[this.user.userId]], ); this.notification.add( - this.env._t("The synchronization with Outlook calendar was successfully stopped."), + _t("The synchronization with Outlook calendar was successfully stopped."), { - title: this.env._t("Success"), + title: _t("Success"), type: "success", }, ); diff --git a/addons/mrp/static/src/components/bom_overview_display_filter/mrp_bom_overview_display_filter.js b/addons/mrp/static/src/components/bom_overview_display_filter/mrp_bom_overview_display_filter.js index 95a11399cf8..7a696758eea 100644 --- a/addons/mrp/static/src/components/bom_overview_display_filter/mrp_bom_overview_display_filter.js +++ b/addons/mrp/static/src/components/bom_overview_display_filter/mrp_bom_overview_display_filter.js @@ -1,4 +1,6 @@ /** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { DropdownItem } from "@web/core/dropdown/dropdown_item"; @@ -7,10 +9,10 @@ const { Component } = owl; export class BomOverviewDisplayFilter extends Component { setup() { this.displayOptions = { - availabilities: this.env._t('Availabilities'), - leadTimes: this.env._t('Lead Times'), - costs: this.env._t('Costs'), - operations: this.env._t('Operations'), + availabilities: _t('Availabilities'), + leadTimes: _t('Lead Times'), + costs: _t('Costs'), + operations: _t('Operations'), }; } diff --git a/addons/mrp/static/src/components/bom_overview_line/mrp_bom_overview_line.js b/addons/mrp/static/src/components/bom_overview_line/mrp_bom_overview_line.js index ebf1ee27b59..3368ade051b 100644 --- a/addons/mrp/static/src/components/bom_overview_line/mrp_bom_overview_line.js +++ b/addons/mrp/static/src/components/bom_overview_line/mrp_bom_overview_line.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { formatFloat, formatFloatTime, formatMonetary } from "@web/views/fields/formatters"; @@ -53,7 +54,7 @@ export class BomOverviewLine extends Component { async goToAttachment() { return this.actionService.doAction({ - name: this.env._t("Attachments"), + name: _t("Attachments"), type: "ir.actions.act_window", res_model: "mrp.document", domain: [["id", "in", this.data.attachment_ids]], diff --git a/addons/mrp/static/src/components/mo_overview_display_filter/mrp_mo_overview_display_filter.js b/addons/mrp/static/src/components/mo_overview_display_filter/mrp_mo_overview_display_filter.js index 8062a3f2551..b62bb748181 100644 --- a/addons/mrp/static/src/components/mo_overview_display_filter/mrp_mo_overview_display_filter.js +++ b/addons/mrp/static/src/components/mo_overview_display_filter/mrp_mo_overview_display_filter.js @@ -1,19 +1,21 @@ /** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { BomOverviewDisplayFilter } from "../bom_overview_display_filter/mrp_bom_overview_display_filter"; export class MoOverviewDisplayFilter extends BomOverviewDisplayFilter { setup() { if (!this.props.limited) { this.displayOptions = { - replenishments: this.env._t("Replenishments"), - availabilities: this.env._t("Availabilities"), - receipts: this.env._t("Receipts"), + replenishments: _t("Replenishments"), + availabilities: _t("Availabilities"), + receipts: _t("Receipts"), }; } this.displayOptions = { ...(this.displayOptions || {}), - moCosts: this.env._t("MO Costs"), - productCosts: this.env._t("Product Costs"), + moCosts: _t("MO Costs"), + productCosts: _t("Product Costs"), }; } } diff --git a/addons/mrp/static/src/components/mo_overview_line/mrp_mo_overview_line.js b/addons/mrp/static/src/components/mo_overview_line/mrp_mo_overview_line.js index 994d7a27359..b7f3848301c 100644 --- a/addons/mrp/static/src/components/mo_overview_line/mrp_mo_overview_line.js +++ b/addons/mrp/static/src/components/mo_overview_line/mrp_mo_overview_line.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component } from "@odoo/owl"; import { useService } from "@web/core/utils/hooks"; import { formatFloat, formatFloatTime, formatMonetary } from "@web/views/fields/formatters"; @@ -111,7 +112,7 @@ export class MoOverviewLine extends Component { } get foldButtonTitle() { - return this.props.isFolded ? this.env._t("Unfold") : this.env._t("Fold"); + return this.props.isFolded ? _t("Unfold") : _t("Fold"); } get forecastAction() { diff --git a/addons/mrp/static/src/views/fields/google_slides_viewer.js b/addons/mrp/static/src/views/fields/google_slides_viewer.js index 4807c9ff192..9de0c3b2878 100644 --- a/addons/mrp/static/src/views/fields/google_slides_viewer.js +++ b/addons/mrp/static/src/views/fields/google_slides_viewer.js @@ -45,7 +45,7 @@ export class SlidesViewer extends CharField { onLoadFailed() { this.state.isValid = false; - this.notification.add(this.env._t("Could not display the selected spreadsheet"), { + this.notification.add(_t("Could not display the selected spreadsheet"), { type: "danger", }); } diff --git a/addons/point_of_sale/static/src/app/barcode/barcode_reader_service.js b/addons/point_of_sale/static/src/app/barcode/barcode_reader_service.js index 5a980af63f3..61f6b8d5d8e 100644 --- a/addons/point_of_sale/static/src/app/barcode/barcode_reader_service.js +++ b/addons/point_of_sale/static/src/app/barcode/barcode_reader_service.js @@ -1,12 +1,13 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { Mutex } from "@web/core/utils/concurrency"; import { session } from "@web/session"; import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; import { ErrorBarcodePopup } from "@point_of_sale/app/barcode/error_popup/barcode_error_popup"; import { BarcodeParser } from "@barcodes/js/barcode_parser"; -import { GS1BarcodeError } from '@barcodes_gs1_nomenclature/js/barcode_parser'; +import { GS1BarcodeError } from "@barcodes_gs1_nomenclature/js/barcode_parser"; export class BarcodeReader { static serviceDependencies = ["popup", "hardware_proxy"]; @@ -130,7 +131,9 @@ export const barcodeReaderService = { orm, session.fallback_nomenclature_id ); - barcodeReader.fallbackParser = new BarcodeParser({ nomenclature: fallbackNomenclature }); + barcodeReader.fallbackParser = new BarcodeParser({ + nomenclature: fallbackNomenclature, + }); } barcode.bus.addEventListener("barcode_scanned", (ev) => { @@ -138,8 +141,8 @@ export const barcodeReaderService = { barcodeReader.scan(ev.detail.barcode); } else { popup.add(ErrorPopup, { - title: env._t("Unable to parse barcode"), - body: env._t( + title: _t("Unable to parse barcode"), + body: _t( "No barcode nomenclature has been configured. This can be changed in the configuration settings." ), }); diff --git a/addons/point_of_sale/static/src/app/barcode/error_popup/barcode_error_popup.js b/addons/point_of_sale/static/src/app/barcode/error_popup/barcode_error_popup.js index 6d844d4daaa..ef3637574d5 100644 --- a/addons/point_of_sale/static/src/app/barcode/error_popup/barcode_error_popup.js +++ b/addons/point_of_sale/static/src/app/barcode/error_popup/barcode_error_popup.js @@ -16,6 +16,6 @@ export class ErrorBarcodePopup extends ErrorPopup { }; get translatedMessage() { - return this.env._t(this.props.message); + return _t(this.props.message); } } diff --git a/addons/point_of_sale/static/src/app/debug/debug_widget.js b/addons/point_of_sale/static/src/app/debug/debug_widget.js index 5f6c1b9eb07..6b37f3fc730 100644 --- a/addons/point_of_sale/static/src/app/debug/debug_widget.js +++ b/addons/point_of_sale/static/src/app/debug/debug_widget.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { parseFloat } from "@web/views/fields/parsers"; import { Transition } from "@web/core/transition"; import { constrain, getLimits, useMovable } from "@point_of_sale/app/utils/movable_hook"; @@ -93,8 +94,8 @@ export class DebugWidget extends Component { } async deleteOrders() { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Delete Paid Orders?"), - body: this.env._t( + title: _t("Delete Paid Orders?"), + body: _t( "This operation will permanently destroy all paid orders from the local storage. You will lose all the data. This operation cannot be undone." ), }); @@ -105,8 +106,8 @@ export class DebugWidget extends Component { } async deleteUnpaidOrders() { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Delete Unpaid Orders?"), - body: this.env._t( + title: _t("Delete Unpaid Orders?"), + body: _t( "This operation will destroy all unpaid orders in the browser. You will lose all the unsaved data and exit the point of sale. This operation cannot be undone." ), }); @@ -132,7 +133,10 @@ export class DebugWidget extends Component { } } get paidOrdersFilename() { - return `${this.env._t("paid orders")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.json`; + return `${_t("paid orders")} ${serializeDateTime(DateTime.now()).replace( + /:|\s/gi, + "-" + )}.json`; } get paidOrdersURL() { var URL = window.URL || window.webkitURL; @@ -148,7 +152,10 @@ export class DebugWidget extends Component { } } get unpaidOrdersFilename() { - return `${this.env._t("unpaid orders")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.json`; + return `${_t("unpaid orders")} ${serializeDateTime(DateTime.now()).replace( + /:|\s/gi, + "-" + )}.json`; } get unpaidOrdersURL() { var URL = window.URL || window.webkitURL; diff --git a/addons/point_of_sale/static/src/app/errors/popups/error_traceback_popup.js b/addons/point_of_sale/static/src/app/errors/popups/error_traceback_popup.js index f87077dc8e6..39f0863da76 100644 --- a/addons/point_of_sale/static/src/app/errors/popups/error_traceback_popup.js +++ b/addons/point_of_sale/static/src/app/errors/popups/error_traceback_popup.js @@ -29,11 +29,11 @@ export class ErrorTracebackPopup extends ErrorPopup { return URL.createObjectURL(blob); } get tracebackFilename() { - return `${this.env._t("error")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.txt`; + return `${_t("error")} ${serializeDateTime(DateTime.now()).replace(/:|\s/gi, "-")}.txt`; } emailTraceback() { const address = this.pos.company.email; - const subject = this.env._t("IMPORTANT: Bug Report From Odoo Point Of Sale"); + const subject = _t("IMPORTANT: Bug Report From Odoo Point Of Sale"); window.open( "mailto:" + address + diff --git a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js index 19a7f6c9008..8ad61ce69bc 100644 --- a/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js +++ b/addons/point_of_sale/static/src/app/navbar/cash_move_popup/cash_move_popup.js @@ -40,11 +40,11 @@ export class CashMovePopup extends AbstractAwaitablePopup { if (!(err instanceof InvalidNumberError)) { throw err; } - this.state.errorMessage = this.env._t("Invalid amount"); + this.state.errorMessage = _t("Invalid amount"); return; } if (amount < 0) { - this.state.errorMessage = this.env._t("Insert a positive amount"); + this.state.errorMessage = _t("Insert a positive amount"); return; } const formattedAmount = this.env.utils.formatCurrency(amount); @@ -92,7 +92,7 @@ export class CashMovePopup extends AbstractAwaitablePopup { } this.props.close(); this.notification.add( - this.env._t("Successfully made a cash %s of %s.", type, formattedAmount), + _t("Successfully made a cash %s of %s.", type, formattedAmount), 3000 ); } @@ -114,6 +114,8 @@ export class CashMovePopup extends AbstractAwaitablePopup { this.amountInput.el.focus(); } format(value) { - return this.env.utils.isValidFloat(value) ? this.env.utils.formatCurrency(parseFloat(value)) : "!!!"; + return this.env.utils.isValidFloat(value) + ? this.env.utils.formatCurrency(parseFloat(value)) + : "!!!"; } } diff --git a/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js b/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js index 9c4495ac81e..de819d10545 100644 --- a/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js +++ b/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js @@ -38,11 +38,14 @@ export class ClosePosPopup extends AbstractAwaitablePopup { Object.assign(this.state, this.props.info.state); useValidateCashInput("closingCashInput"); if (this.otherPaymentMethods && this.otherPaymentMethods.length > 0) { - this.otherPaymentMethods.forEach(pm => { + this.otherPaymentMethods.forEach((pm) => { if (this._getShowDiff(pm)) { - useValidateCashInput("closingCashInput_" + pm.id, this.state.payments[pm.id].counted); + useValidateCashInput( + "closingCashInput_" + pm.id, + this.state.payments[pm.id].counted + ); } - }) + }); } } //@override @@ -51,8 +54,8 @@ export class ClosePosPopup extends AbstractAwaitablePopup { this.closeSession(); } else if (this.hasUserAuthority()) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Payments Difference"), - body: this.env._t( + title: _t("Payments Difference"), + body: _t( "Do you want to accept payments difference and post a profit/loss journal entry?" ), }); @@ -61,13 +64,13 @@ export class ClosePosPopup extends AbstractAwaitablePopup { } } else { await this.popup.add(ConfirmPopup, { - title: this.env._t("Payments Difference"), - body: this.env._t( + title: _t("Payments Difference"), + body: _t( "The maximum difference allowed is %s.\n\ Please contact your manager to accept the closing difference.", this.env.utils.formatCurrency(this.amountAuthorizedDiff) ), - confirmText: this.env._t("OK"), + confirmText: _t("OK"), }); } } @@ -103,12 +106,12 @@ export class ClosePosPopup extends AbstractAwaitablePopup { } } async downloadSalesReport() { - return this.report.download("point_of_sale.sale_details_report", [ - this.pos.pos_session.id, - ]); + return this.report.download("point_of_sale.sale_details_report", [this.pos.pos_session.id]); } handleInputChange(paymentId, event) { - if (event.target.classList.contains('invalid-cash-input')) return; + if (event.target.classList.contains("invalid-cash-input")) { + return; + } let expectedAmount; if (paymentId === this.defaultCashDetails?.id) { this.manualInputCashCount = true; diff --git a/addons/point_of_sale/static/src/app/screens/partner_list/partner_editor/partner_editor.js b/addons/point_of_sale/static/src/app/screens/partner_list/partner_editor/partner_editor.js index 02f5662d377..7c5d92133e3 100644 --- a/addons/point_of_sale/static/src/app/screens/partner_list/partner_editor/partner_editor.js +++ b/addons/point_of_sale/static/src/app/screens/partner_list/partner_editor/partner_editor.js @@ -87,10 +87,8 @@ export class PartnerDetailsEdit extends Component { const file = event.target.files[0]; if (!file.type.match(/image.*/)) { await this.popup.add(ErrorPopup, { - title: this.env._t("Unsupported File Format"), - body: this.env._t( - "Only web-compatible Image formats such as .png or .jpeg are supported." - ), + title: _t("Unsupported File Format"), + body: _t("Only web-compatible Image formats such as .png or .jpeg are supported."), }); } else { const imageUrl = await getDataURLFromFile(file); @@ -133,8 +131,8 @@ export class PartnerDetailsEdit extends Component { img.addEventListener("load", () => resolve(img)); img.addEventListener("error", () => { this.popup.add(ErrorPopup, { - title: this.env._t("Loading Image Error"), - body: this.env._t("Encountered error when loading image. Please try again."), + title: _t("Loading Image Error"), + body: _t("Encountered error when loading image. Please try again."), }); resolve(false); }); diff --git a/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js b/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js index ba9380de989..129b593373d 100644 --- a/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js +++ b/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { debounce } from "@web/core/utils/timing"; import { useService } from "@web/core/utils/hooks"; @@ -127,14 +128,11 @@ export class PartnerListScreen extends Component { const result = await this.searchPartner(); if (result.length > 0) { this.notification.add( - this.env._t('%s customer(s) found for "%s".', result.length, this.state.query), + _t('%s customer(s) found for "%s".', result.length, this.state.query), 3000 ); } else { - this.notification.add( - this.env._t('No more customer found for "%s".', this.state.query), - 3000 - ); + this.notification.add(_t('No more customer found for "%s".', this.state.query), 3000); } } _clearSearch() { diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_lines/payment_lines.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_lines/payment_lines.js index 59483156e3a..e9963f75a0e 100644 --- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_lines/payment_lines.js +++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_lines/payment_lines.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup"; import { useService } from "@web/core/utils/hooks"; import { Component, useState } from "@odoo/owl"; @@ -28,7 +29,7 @@ export class PaymentScreenPaymentLines extends Component { if (this.ui.isSmall) { const { confirmed, payload } = await this.popup.add(NumberPopup, { - title: this.env._t("New amount"), + title: _t("New amount"), startingValue: parseFloat(paymentline.amount), isInputSelected: true, nbrDecimal: this.pos.currency.decimal_places, diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js index 0fb953f61ae..4631863fae7 100644 --- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js +++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { parseFloat } from "@web/views/fields/parsers"; import { useErrorHandlers } from "@point_of_sale/app/utils/hooks"; import { registry } from "@web/core/registry"; @@ -46,8 +47,8 @@ export class PaymentScreen extends Component { showMaxValueError() { this.popup.add(ErrorPopup, { - title: this.env._t("Maximum value reached"), - body: this.env._t( + title: _t("Maximum value reached"), + body: _t( "The amount cannot be higher than the due amount if you don't have a cash payment method configured." ), }); @@ -95,8 +96,8 @@ export class PaymentScreen extends Component { return true; } else { this.popup.add(ErrorPopup, { - title: this.env._t("Error"), - body: this.env._t("There is already an electronic payment in progress."), + title: _t("Error"), + body: _t("There is already an electronic payment in progress."), }); return false; } @@ -157,7 +158,7 @@ export class PaymentScreen extends Component { const value = tip === 0 && change > 0 ? change : tip; const { confirmed, payload } = await this.popup.add(NumberPopup, { - title: tip ? this.env._t("Change Tip") : this.env._t("Add Tip"), + title: tip ? _t("Change Tip") : _t("Add Tip"), startingValue: value, isInputSelected: true, nbrDecimal: this.pos.currency.decimal_places, @@ -171,7 +172,7 @@ export class PaymentScreen extends Component { async toggleShippingDatePicker() { if (!this.currentOrder.getShippingDate()) { const { confirmed, payload: shippingDate } = await this.popup.add(DatePickerPopup, { - title: this.env._t("Select the shipping date"), + title: _t("Select the shipping date"), }); if (confirmed) { this.currentOrder.setShippingDate(shippingDate); @@ -208,8 +209,8 @@ export class PaymentScreen extends Component { if (this.pos.config.cash_rounding) { if (!this.pos.get_order().check_paymentlines_rounding()) { this.popup.add(ErrorPopup, { - title: this.env._t("Rounding error in payment lines"), - body: this.env._t( + title: _t("Rounding error in payment lines"), + body: _t( "The amount of your payment lines must be rounded to validate the transaction." ), }); @@ -283,8 +284,8 @@ export class PaymentScreen extends Component { const postPushResult = await this._postPushOrderResolve(this.currentOrder, ordersServerId); if (!postPushResult) { this.popup.add(ErrorPopup, { - title: this.env._t("Error: no internet connection."), - body: this.env._t("Some, if not all, post-processing after syncing order failed."), + title: _t("Error: no internet connection."), + body: _t("Some, if not all, post-processing after syncing order failed."), }); } } @@ -296,8 +297,8 @@ export class PaymentScreen extends Component { // Ask the user to sync the remaining unsynced orders. if (suggestToSync && this.pos.db.get_orders().length) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Remaining unsynced orders"), - body: this.env._t("There are unsynced orders. Do you want to sync these orders?"), + title: _t("Remaining unsynced orders"), + body: _t("There are unsynced orders. Do you want to sync these orders?"), }); if (confirmed) { // NOTE: Not yet sure if this should be awaited or not. @@ -327,8 +328,8 @@ export class PaymentScreen extends Component { async _isOrderValid(isForceValidate) { if (this.currentOrder.get_orderlines().length === 0 && this.currentOrder.is_to_invoice()) { this.popup.add(ErrorPopup, { - title: this.env._t("Empty Order"), - body: this.env._t( + title: _t("Empty Order"), + body: _t( "There must be at least one product in your order before it can be validated and invoiced." ), }); @@ -341,11 +342,8 @@ export class PaymentScreen extends Component { if (splitPayments.length && !this.currentOrder.get_partner()) { const paymentMethod = splitPayments[0].payment_method; const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Customer Required"), - body: this.env._t( - "Customer is required for %s payment method.", - paymentMethod.name - ), + title: _t("Customer Required"), + body: _t("Customer is required for %s payment method.", paymentMethod.name), }); if (confirmed) { this.selectPartner(); @@ -358,8 +356,8 @@ export class PaymentScreen extends Component { !this.currentOrder.get_partner() ) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Please select the Customer"), - body: this.env._t( + title: _t("Please select the Customer"), + body: _t( "You need to select the customer before you can invoice or ship an order." ), }); @@ -375,8 +373,8 @@ export class PaymentScreen extends Component { !(partner.name && partner.street && partner.city && partner.country_id) ) { this.popup.add(ErrorPopup, { - title: this.env._t("Incorrect address for shipping"), - body: this.env._t("The selected customer needs an address."), + title: _t("Incorrect address for shipping"), + body: _t("The selected customer needs an address."), }); return false; } @@ -385,7 +383,7 @@ export class PaymentScreen extends Component { this.currentOrder.get_total_with_tax() != 0 && this.currentOrder.get_paymentlines().length === 0 ) { - this.notification.add(this.env._t("Select a payment method to validate the order.")); + this.notification.add(_t("Select a payment method to validate the order.")); return false; } @@ -396,8 +394,8 @@ export class PaymentScreen extends Component { if (this.currentOrder.has_not_valid_rounding()) { var line = this.currentOrder.has_not_valid_rounding(); this.popup.add(ErrorPopup, { - title: this.env._t("Incorrect rounding"), - body: this.env._t( + title: _t("Incorrect rounding"), + body: _t( "You have to round your payments lines." + line.amount + " is not rounded." ), }); @@ -414,8 +412,8 @@ export class PaymentScreen extends Component { ) { if (!this.pos.payment_methods.some((pm) => pm.is_cash_count)) { this.popup.add(ErrorPopup, { - title: this.env._t("Cannot return change without a cash payment method"), - body: this.env._t( + title: _t("Cannot return change without a cash payment method"), + body: _t( "There is no cash payment method available in this point of sale to handle the change.\n\n Please pay the exact amount or add a cash payment method in the point of sale configuration" ), }); @@ -431,17 +429,17 @@ export class PaymentScreen extends Component { ) { this.popup .add(ConfirmPopup, { - title: this.env._t("Please Confirm Large Amount"), + title: _t("Please Confirm Large Amount"), body: - this.env._t("Are you sure that the customer wants to pay") + + _t("Are you sure that the customer wants to pay") + " " + this.env.utils.formatCurrency(this.currentOrder.get_total_paid()) + " " + - this.env._t("for an order of") + + _t("for an order of") + " " + this.env.utils.formatCurrency(this.currentOrder.get_total_with_tax()) + " " + - this.env._t('? Clicking "Confirm" will validate the payment.'), + _t('? Clicking "Confirm" will validate the payment.'), }) .then(({ confirmed }) => { if (confirmed) { diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/customer_note_button/customer_note_button.js b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/customer_note_button/customer_note_button.js index 94e6d56c718..0f8e85f400a 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/customer_note_button/customer_note_button.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/customer_note_button/customer_note_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { TextAreaPopup } from "@point_of_sale/app/utils/input_popups/textarea_popup"; @@ -21,7 +22,7 @@ export class OrderlineCustomerNoteButton extends Component { } const { confirmed, payload: inputNote } = await this.popup.add(TextAreaPopup, { startingValue: selectedOrderline.get_customer_note(), - title: this.env._t("Add Customer Note"), + title: _t("Add Customer Note"), }); if (confirmed) { diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/fiscal_position_button/fiscal_position_button.js b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/fiscal_position_button/fiscal_position_button.js index 3e46e8e6bf0..159cb268c0a 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/fiscal_position_button/fiscal_position_button.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/fiscal_position_button/fiscal_position_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup"; @@ -19,14 +20,14 @@ export class SetFiscalPositionButton extends Component { get currentFiscalPositionName() { return this.currentOrder && this.currentOrder.fiscal_position ? this.currentOrder.fiscal_position.display_name - : this.env._t("Tax"); + : _t("Tax"); } async click() { const currentFiscalPosition = this.currentOrder.fiscal_position; const fiscalPosList = [ { id: -1, - label: this.env._t("None"), + label: _t("None"), isSelected: !currentFiscalPosition, }, ]; @@ -43,7 +44,7 @@ export class SetFiscalPositionButton extends Component { const { confirmed, payload: selectedFiscalPosition } = await this.popup.add( SelectionPopup, { - title: this.env._t("Select Fiscal Position"), + title: _t("Select Fiscal Position"), list: fiscalPosList, } ); diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/pricelist_button/pricelist_button.js b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/pricelist_button/pricelist_button.js index c32fc2cebf9..a8fb47d6bcb 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/pricelist_button/pricelist_button.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/pricelist_button/pricelist_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup"; @@ -18,7 +19,7 @@ export class SetPricelistButton extends Component { } get currentPricelistName() { const order = this.currentOrder; - return order && order.pricelist ? order.pricelist.display_name : this.env._t("Pricelist"); + return order && order.pricelist ? order.pricelist.display_name : _t("Pricelist"); } async click() { // Create the list to be passed to the SelectionPopup. @@ -35,14 +36,14 @@ export class SetPricelistButton extends Component { if (!this.pos.default_pricelist) { selectionList.push({ id: null, - label: this.env._t("Default Price"), + label: _t("Default Price"), isSelected: !this.currentOrder.pricelist, item: null, }); } const { confirmed, payload: selectedPricelist } = await this.popup.add(SelectionPopup, { - title: this.env._t("Select the pricelist"), + title: _t("Select the pricelist"), list: selectionList, }); diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/save_button/save_button.js b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/save_button/save_button.js index 7b57dbc7407..ba6a2e1badb 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/save_button/save_button.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/control_buttons/save_button/save_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component } from "@odoo/owl"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; @@ -15,11 +16,11 @@ export class SaveButton extends Component { onClick() { const orderline = this.pos.get_order().get_selected_orderline(); if (!orderline) { - this.notification.add(this.env._t("You cannot save an empty order"), 3000); + this.notification.add(_t("You cannot save an empty order"), 3000); return; } this._selectEmptyOrder(); - this.notification.add(this.env._t("Order saved for later"), 3000); + this.notification.add(_t("Order saved for later"), 3000); } _selectEmptyOrder() { const orders = this.pos.get_order_list(); diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/order/order.js b/addons/point_of_sale/static/src/app/screens/product_screen/order/order.js index 86d199fac70..29cbb409ed3 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/order/order.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/order/order.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { EditListPopup } from "@point_of_sale/app/store/select_lot_popup/select_lot_popup"; @@ -50,7 +51,7 @@ export class OrderWidget extends Component { const isAllowOnlyOneLot = orderline.product.isAllowOnlyOneLot(); const packLotLinesToEdit = orderline.getPackLotLinesToEdit(isAllowOnlyOneLot); const { confirmed, payload } = await this.popup.add(EditListPopup, { - title: this.env._t("Lot/Serial Number(s) Required"), + title: _t("Lot/Serial Number(s) Required"), name: orderline.product.display_name, isSingleItem: isAllowOnlyOneLot, array: packLotLinesToEdit, diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/product_list/product_list.js b/addons/point_of_sale/static/src/app/screens/product_screen/product_list/product_list.js index f9a95ba5ccd..a35a3182bfe 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/product_list/product_list.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/product_list/product_list.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { useService } from "@web/core/utils/hooks"; import { identifyError } from "@point_of_sale/app/errors/error_handlers"; @@ -80,14 +81,11 @@ export class ProductsWidget extends Component { const result = await this.loadProductFromDB(); if (result.length > 0) { this.notification.add( - this.env._t('%s product(s) found for "%s".', result.length, searchProductWord), + _t('%s product(s) found for "%s".', result.length, searchProductWord), 3000 ); } else { - this.notification.add( - this.env._t('No more product found for "%s".', searchProductWord), - 3000 - ); + this.notification.add(_t('No more product found for "%s".', searchProductWord), 3000); } if (this.state.previousSearchWord === searchProductWord) { this.state.currentOffset += result.length; @@ -135,8 +133,8 @@ export class ProductsWidget extends Component { identifiedError instanceof ConnectionAbortedError ) { return this.popup.add(OfflineErrorPopup, { - title: this.env._t("Network Error"), - body: this.env._t( + title: _t("Network Error"), + body: _t( "Product is not loaded. Tried loading the product from the server but there is a network error." ), }); @@ -153,8 +151,8 @@ export class ProductsWidget extends Component { ); if (!successful) { this.popup.add(ErrorPopup, { - title: this.env._t("Demo products are no longer available"), - body: this.env._t( + title: _t("Demo products are no longer available"), + body: _t( "A valid product already exists for Point of Sale. Therefore, demonstration products cannot be loaded." ), }); diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js index c4b16f1b961..942d5e63a27 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js @@ -110,8 +110,8 @@ export class ProductScreen extends ControlButtonsMixin(Component) { if (selectedLine.noDecrease) { this.popup.add(ErrorPopup, { - title: this.env._t("Invalid action"), - body: this.env._t("You are not allowed to change this quantity"), + title: _t("Invalid action"), + body: _t("You are not allowed to change this quantity"), }); return; } @@ -205,7 +205,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { if (!partner) { // find the partner in the backend by the barcode const foundPartnerIds = await this.orm.search("res.partner", [ - ["barcode", "=", code.code] + ["barcode", "=", code.code], ]); if (foundPartnerIds.length) { await this.pos._loadPartners(foundPartnerIds); @@ -263,7 +263,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { this.numberBuffer.reset(); const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, { startingValue: 0, - title: this.env._t("Set the new quantity"), + title: _t("Set the new quantity"), }); const newQuantity = inputNumber && inputNumber !== "" ? parseFloat(inputNumber) : null; if (confirmed && newQuantity !== null) { @@ -341,7 +341,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { this.pos.showScreen("TicketScreen", { ui: { filter: "SYNCED", searchDetails }, }); - this.notification.add(this.env._t("The order has been already paid."), 3000); + this.notification.add(_t("The order has been already paid."), 3000); this.pos.removeOrder(this.pos.get_order(), false); this.pos.add_new_order(); return; diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js index b497528c9fd..7cac25140d6 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/abstract_receipt_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup"; import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; @@ -51,8 +52,8 @@ export class AbstractReceiptScreen extends Component { return true; } catch { await this.popup.add(ErrorPopup, { - title: this.env._t("Printing is not supported on some browsers"), - body: this.env._t( + title: _t("Printing is not supported on some browsers"), + body: _t( "Printing is not supported on some browsers due to no default printing protocol " + "is available. It is possible to print your tickets by making use of an IoT Box." ), diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js index 7ef1328c4df..82047005f15 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useErrorHandlers } from "@point_of_sale/app/utils/hooks"; import { AbstractReceiptScreen } from "@point_of_sale/app/screens/receipt_screen/abstract_receipt_screen"; import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup"; @@ -61,7 +62,7 @@ export class ReceiptScreen extends AbstractReceiptScreen { onSendEmail() { if (this.buttonMailReceipt.el.classList.contains("fa-spin")) { this.orderUiState.emailSuccessful = false; - this.orderUiState.emailNotice = this.env._t("Sending in progress."); + this.orderUiState.emailNotice = _t("Sending in progress."); return; } this.buttonMailReceipt.el.className = "fa fa-fw fa-spin fa-circle-o-notch"; @@ -70,7 +71,7 @@ export class ReceiptScreen extends AbstractReceiptScreen { if (!this.isValidEmail()) { this.orderUiState.emailSuccessful = false; this.buttonMailReceipt.el.className = "fa fa-paper-plane"; - this.orderUiState.emailNotice = this.env._t("Invalid email."); + this.orderUiState.emailNotice = _t("Invalid email."); return; } @@ -79,12 +80,10 @@ export class ReceiptScreen extends AbstractReceiptScreen { try { await this._sendReceiptToCustomer(); this.orderUiState.emailSuccessful = true; - this.orderUiState.emailNotice = this.env._t("Email sent."); + this.orderUiState.emailNotice = _t("Email sent."); } catch { this.orderUiState.emailSuccessful = false; - this.orderUiState.emailNotice = this.env._t( - "Sending email failed. Please try again." - ); + this.orderUiState.emailNotice = _t("Sending email failed. Please try again."); } this.buttonMailReceipt.el.className = "fa fa-paper-plane"; }, 1000); @@ -196,8 +195,8 @@ export class ReceiptScreen extends AbstractReceiptScreen { const order_server_id = this.pos.validated_orders_name_server_id_map[orderName]; if (!order_server_id) { this.popup.add(OfflineErrorPopup, { - title: this.env._t("Unsynced order"), - body: this.env._t( + title: _t("Unsynced order"), + body: _t( "This order is not yet synced to server. Make sure it is synced then try again." ), }); diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/invoice_button/invoice_button.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/invoice_button/invoice_button.js index 29882ede9ce..e4650dffe33 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/invoice_button/invoice_button.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/invoice_button/invoice_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup"; @@ -24,9 +25,9 @@ export class InvoiceButton extends Component { } get commandName() { if (!this.props.order) { - return this.env._t("Invoice"); + return _t("Invoice"); } else { - return this.isAlreadyInvoiced ? this.env._t("Reprint Invoice") : this.env._t("Invoice"); + return this.isAlreadyInvoiced ? _t("Reprint Invoice") : _t("Invoice"); } } async _downloadInvoice(orderId) { @@ -48,8 +49,8 @@ export class InvoiceButton extends Component { } else { // NOTE: error here is most probably undefined this.popup.add(ErrorPopup, { - title: this.env._t("Network Error"), - body: this.env._t("Unable to download invoice."), + title: _t("Network Error"), + body: _t("Unable to download invoice."), }); } } @@ -75,8 +76,8 @@ export class InvoiceButton extends Component { // Write to pos.order the selected partner. if (!order.get_partner()) { const { confirmed: confirmedPopup } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Need customer to invoice"), - body: this.env._t("Do you want to open the customer list to select customer?"), + title: _t("Need customer to invoice"), + body: _t("Do you want to open the customer list to select customer?"), }); if (!confirmedPopup) { return; diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/order_details/orderline_details.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/order_details/orderline_details.js index 7437dc3a79c..a052504b805 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/order_details/orderline_details.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/order_details/orderline_details.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component } from "@odoo/owl"; import { formatFloat } from "@web/views/fields/formatters"; import { roundPrecision as round_pr } from "@web/core/utils/numbers"; @@ -71,9 +72,9 @@ export class OrderlineDetails extends Component { return this.env.utils.formatProductQty(toRefundDetail && toRefundDetail.qty); } getRefundingMessage() { - return this.env._t("Refunding %s in ", this.getFormattedToRefundQty()); + return _t("Refunding %s in ", this.getFormattedToRefundQty()); } getToRefundMessage() { - return this.env._t("To Refund: %s", this.getFormattedToRefundQty()); + return _t("To Refund: %s", this.getFormattedToRefundQty()); } } diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js index 774c15e6cc4..ba9c1423f83 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js @@ -126,8 +126,8 @@ export class TicketScreen extends Component { order.get_orderlines().length > 0 ) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Existing orderlines"), - body: this.env._t( + title: _t("Existing orderlines"), + body: _t( "%s has a total amount of %s, are you sure you want to delete this order?", order.name, this.getTotal(order) @@ -208,8 +208,8 @@ export class TicketScreen extends Component { if (quantity > refundableQty) { this.numberBuffer.reset(); this.popup.add(ErrorPopup, { - title: this.env._t("Maximum Exceeded"), - body: this.env._t( + title: _t("Maximum Exceeded"), + body: _t( "The requested quantity to be refunded is higher than the ordered quantity. %s is requested while only %s can be refunded.", quantity, refundableQty @@ -344,7 +344,7 @@ export class TicketScreen extends Component { } getStatus(order) { if (order.locked) { - return this.env._t("Paid"); + return _t("Paid"); } else { const screen = order.get_screen_data(); return this._getOrderStates().get(this._getScreenToStatusMap()[screen.name]).text; @@ -561,7 +561,7 @@ export class TicketScreen extends Component { } _getFilterOptions() { const orderStates = this._getOrderStates(); - orderStates.set("SYNCED", { text: this.env._t("Paid") }); + orderStates.set("SYNCED", { text: _t("Paid") }); return orderStates; } /** @@ -571,18 +571,18 @@ export class TicketScreen extends Component { const fields = { RECEIPT_NUMBER: { repr: (order) => order.name, - displayName: this.env._t("Receipt Number"), + displayName: _t("Receipt Number"), modelField: "pos_reference", }, DATE: { repr: (order) => deserializeDate(order.creation_date).toFormat("yyyy-MM-dd HH:mm a"), - displayName: this.env._t("Date"), + displayName: _t("Date"), modelField: "date_order", }, PARTNER: { repr: (order) => order.get_partner_name(), - displayName: this.env._t("Customer"), + displayName: _t("Customer"), modelField: "partner_id.complete_name", }, }; @@ -590,7 +590,7 @@ export class TicketScreen extends Component { if (this.showCardholderName()) { fields.CARDHOLDER_NAME = { repr: (order) => order.get_cardholder_name(), - displayName: this.env._t("Cardholder Name"), + displayName: _t("Cardholder Name"), modelField: "payment_ids.cardholder_name", }; } @@ -620,20 +620,20 @@ export class TicketScreen extends Component { // We need the items to be ordered, therefore, Map is used instead of normal object. const states = new Map(); states.set("ACTIVE_ORDERS", { - text: this.env._t("All active orders"), + text: _t("All active orders"), }); // The spaces are important to make sure the following states // are under the category of `All active orders`. states.set("ONGOING", { - text: this.env._t("Ongoing"), + text: _t("Ongoing"), indented: true, }); states.set("PAYMENT", { - text: this.env._t("Payment"), + text: _t("Payment"), indented: true, }); states.set("RECEIPT", { - text: this.env._t("Receipt"), + text: _t("Receipt"), indented: true, }); return states; diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index 387bc8dc531..d4dbf2fa1e8 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -4,7 +4,12 @@ import { formatFloat } from "@web/views/fields/formatters"; import { uuidv4 } from "@point_of_sale/utils"; // FIXME POSREF - unify use of native parseFloat and web's parseFloat. We probably don't need the native version. import { parseFloat as oParseFloat } from "@web/views/fields/parsers"; -import { formatDate, formatDateTime, serializeDateTime, deserializeDate } from "@web/core/l10n/dates"; +import { + formatDate, + formatDateTime, + serializeDateTime, + deserializeDate, +} from "@web/core/l10n/dates"; import { roundDecimals as round_di, roundPrecision as round_pr, @@ -169,7 +174,7 @@ export class Product extends PosModel { const { confirmed, payload } = await this.pos.env.services.popup.add( EditListPopup, { - title: this.pos.env._t("Lot/Serial Number(s) Required"), + title: _t("Lot/Serial Number(s) Required"), name: this.display_name, isSingleItem: isAllowOnlyOneLot, array: packLotLinesToEdit, @@ -309,22 +314,14 @@ export class Product extends PosModel { } get_display_price(pricelist, quantity) { const order = this.pos.get_order(); - const taxes = this.pos.get_taxes_after_fp( - this.taxes_id, - order && order.fiscal_position - ); + const taxes = this.pos.get_taxes_after_fp(this.taxes_id, order && order.fiscal_position); const currentTaxes = this.pos.getTaxesByIds(this.taxes_id); const priceAfterFp = this.pos.computePriceAfterFp( - this.get_price(pricelist, quantity), + this.get_price(pricelist, quantity), currentTaxes ); - const allPrices = this.pos.compute_all( - taxes, - priceAfterFp, - 1, - this.pos.currency.rounding - ); - if (this.pos.config.iface_tax_included === 'total') { + const allPrices = this.pos.compute_all(taxes, priceAfterFp, 1, this.pos.currency.rounding); + if (this.pos.config.iface_tax_included === "total") { return allPrices.total_included; } else { return allPrices.total_excluded; @@ -840,8 +837,8 @@ export class Orderline extends PosModel { return this.get_all_prices(1).priceWithoutTax; } } - getUnitDisplayPriceBeforeDiscount(){ - if (this.pos.config.iface_tax_included === 'total') { + getUnitDisplayPriceBeforeDiscount() { + if (this.pos.config.iface_tax_included === "total") { return this.get_all_prices(1).priceWithTaxBeforeDiscount; } else { return this.get_all_prices(1).priceWithoutTaxBeforeDiscount; @@ -880,13 +877,13 @@ export class Orderline extends PosModel { return this.get_price_without_tax(); } } - get_taxed_lst_unit_price(){ + get_taxed_lst_unit_price() { const lstPrice = this.compute_fixed_price(this.get_lst_price()); - const product = this.get_product(); + const product = this.get_product(); const taxesIds = product.taxes_id; const productTaxes = this.pos.get_taxes_after_fp(taxesIds, this.order.fiscal_position); - const unitPrices = this.compute_all(productTaxes, lstPrice, 1, this.pos.currency.rounding); - if (this.pos.config.iface_tax_included === 'total') { + const unitPrices = this.compute_all(productTaxes, lstPrice, 1, this.pos.currency.rounding); + if (this.pos.config.iface_tax_included === "total") { return unitPrices.total_included; } else { return unitPrices.total_excluded; @@ -1017,7 +1014,7 @@ export class Orderline extends PosModel { display_discount_policy() { return this.order.pricelist ? this.order.pricelist.discount_policy : "with_discount"; } - compute_fixed_price (price) { + compute_fixed_price(price) { return this.pos.computePriceAfterFp(price, this.get_taxes()); } get_fixed_lst_price() { @@ -2190,10 +2187,13 @@ export class Order extends PosModel { _get_ignored_product_ids_total_discount() { return []; } - _reduce_total_discount_callback(sum, orderLine){ - let discountUnitPrice = orderLine.getUnitDisplayPriceBeforeDiscount() * (orderLine.get_discount()/100); - if (orderLine.display_discount_policy() === 'without_discount'){ - discountUnitPrice += orderLine.get_taxed_lst_unit_price() - orderLine.getUnitDisplayPriceBeforeDiscount(); + _reduce_total_discount_callback(sum, orderLine) { + let discountUnitPrice = + orderLine.getUnitDisplayPriceBeforeDiscount() * (orderLine.get_discount() / 100); + if (orderLine.display_discount_policy() === "without_discount") { + discountUnitPrice += + orderLine.get_taxed_lst_unit_price() - + orderLine.getUnitDisplayPriceBeforeDiscount(); } return sum + discountUnitPrice * orderLine.get_quantity(); } @@ -2208,7 +2208,8 @@ export class Order extends PosModel { orderLine.get_quantity(); if (orderLine.display_discount_policy() === "without_discount") { sum += - (orderLine.get_taxed_lst_unit_price() - orderLine.getUnitDisplayPriceBeforeDiscount()) * + (orderLine.get_taxed_lst_unit_price() - + orderLine.getUnitDisplayPriceBeforeDiscount()) * orderLine.get_quantity(); } } diff --git a/addons/point_of_sale/static/src/app/utils/hooks.js b/addons/point_of_sale/static/src/app/utils/hooks.js index 71e1f1cf85a..61dd70d36cd 100644 --- a/addons/point_of_sale/static/src/app/utils/hooks.js +++ b/addons/point_of_sale/static/src/app/utils/hooks.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup"; import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_popup"; import { ErrorTracebackPopup } from "@point_of_sale/app/errors/popups/error_traceback_popup"; @@ -21,36 +23,34 @@ export function useErrorHandlers() { // This error handler receives `error` equivalent to `error.message` of the rpc error. if (error.message === "Backend Invoice") { await popup.add(ConfirmPopup, { - title: this.env._t("Please print the invoice from the backend"), + title: _t("Please print the invoice from the backend"), body: - this.env._t( + _t( "The order has been synchronized earlier. Please make the invoice from the backend for the order: " ) + error.data.order.name, }); } else if (error.code < 0) { // XmlHttpRequest Errors - const title = this.env._t("Unable to sync order"); - const body = this.env._t( + const title = _t("Unable to sync order"); + const body = _t( "Check the internet connection then try to sync again by clicking on the red wifi button (upper right of the screen)." ); await popup.add(OfflineErrorPopup, { title, body }); } else if (error.code === 200) { // OpenERP Server Errors await popup.add(ErrorTracebackPopup, { - title: error.data.message || this.env._t("Server Error"), + title: error.data.message || _t("Server Error"), body: error.data.debug || - this.env._t("The server encountered an error while receiving your order."), + _t("The server encountered an error while receiving your order."), }); } else if (error.code === 700) { // Sweden Fiscal module errors await popup.add(ErrorPopup, { - title: this.env._t("Fiscal data module error"), + title: _t("Fiscal data module error"), body: error.data.error.status || - this.env._t( - "The fiscal data module encountered an error while receiving your order." - ), + _t("The fiscal data module encountered an error while receiving your order."), }); } else if (error.code === 701) { // Belgian Fiscal module errors @@ -61,16 +61,14 @@ export function useErrorHandlers() { bodyMessage = "Fiscal data module is not on."; } await popup.add(ErrorPopup, { - title: this.env._t("Fiscal data module error"), + title: _t("Fiscal data module error"), body: bodyMessage, }); } else { // ??? await popup.add(ErrorPopup, { - title: this.env._t("Unknown Error"), - body: this.env._t( - "The order could not be sent to the server due to an unknown error" - ), + title: _t("Unknown Error"), + body: _t("The order could not be sent to the server due to an unknown error"), }); } }; diff --git a/addons/point_of_sale/static/src/backend/debug_manager.js b/addons/point_of_sale/static/src/backend/debug_manager.js index c04fe13595c..03bfa517ce6 100644 --- a/addons/point_of_sale/static/src/backend/debug_manager.js +++ b/addons/point_of_sale/static/src/backend/debug_manager.js @@ -1,14 +1,15 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; function runPoSJSTests({ env }) { return { type: "item", - description: env._t("Run Point of Sale JS Tests"), + description: _t("Run Point of Sale JS Tests"), callback: () => { env.services.action.doAction({ - name: env._t("JS Tests"), + name: _t("JS Tests"), target: "new", type: "ir.actions.act_url", url: "/pos/ui/tests?debug=assets", diff --git a/addons/pos_discount/static/src/overrides/components/discount_button/discount_button.js b/addons/pos_discount/static/src/overrides/components/discount_button/discount_button.js index d587dc27dee..12c6b8da085 100644 --- a/addons/pos_discount/static/src/overrides/components/discount_button/discount_button.js +++ b/addons/pos_discount/static/src/overrides/components/discount_button/discount_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup"; @@ -17,7 +18,7 @@ export class DiscountButton extends Component { async click() { var self = this; const { confirmed, payload } = await this.popup.add(NumberPopup, { - title: this.env._t("Discount Percentage"), + title: _t("Discount Percentage"), startingValue: this.pos.config.discount_pc, isInputSelected: true, }); @@ -33,8 +34,8 @@ export class DiscountButton extends Component { const product = this.pos.db.get_product_by_id(this.pos.config.discount_product_id[0]); if (product === undefined) { await this.popup.add(ErrorPopup, { - title: this.env._t("No discount product found"), - body: this.env._t( + title: _t("No discount product found"), + body: _t( "The discount product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'." ), }); @@ -72,13 +73,13 @@ export class DiscountButton extends Component { description: `${pc}%, ` + (tax_ids_array.length - ? this.env._t( + ? _t( "Tax: %s", tax_ids_array .map((taxId) => this.pos.taxes_by_id[taxId].amount + "%") .join(", ") ) - : this.env._t("No tax")), + : _t("No tax")), extras: { price_type: "automatic", }, diff --git a/addons/pos_loyalty/static/src/app/control_buttons/e_wallet_button/e_wallet_button.js b/addons/pos_loyalty/static/src/app/control_buttons/e_wallet_button/e_wallet_button.js index 8b2bd945e18..333ff641e02 100644 --- a/addons/pos_loyalty/static/src/app/control_buttons/e_wallet_button/e_wallet_button.js +++ b/addons/pos_loyalty/static/src/app/control_buttons/e_wallet_button/e_wallet_button.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup"; import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; @@ -27,9 +28,7 @@ export class eWalletButton extends Component { } async _onClickWalletButton() { const order = this.pos.get_order(); - const eWalletPrograms = this.pos.programs.filter( - (p) => p.program_type == "ewallet" - ); + const eWalletPrograms = this.pos.programs.filter((p) => p.program_type == "ewallet"); const orderTotal = order.get_total_with_tax(); const eWalletRewards = this._getEWalletRewards(order); if (orderTotal < 0 && eWalletPrograms.length >= 1) { @@ -38,7 +37,7 @@ export class eWalletButton extends Component { selectedProgram = eWalletPrograms[0]; } else { const { confirmed, payload } = await this.popup.add(SelectionPopup, { - title: this.env._t("Refund with eWallet"), + title: _t("Refund with eWallet"), list: eWalletPrograms.map((program) => ({ id: program.id, item: program, @@ -65,7 +64,7 @@ export class eWalletButton extends Component { eWalletReward = eWalletRewards[0]; } else { const { confirmed, payload } = await this.popup.add(SelectionPopup, { - title: this.env._t("Use eWallet to pay"), + title: _t("Use eWallet to pay"), list: eWalletRewards.map(({ reward, coupon_id }) => ({ id: reward.id, item: { reward, coupon_id }, @@ -85,7 +84,7 @@ export class eWalletButton extends Component { if (result !== true) { // Returned an error this.popup.add(ErrorPopup, { - title: this.env._t("Error"), + title: _t("Error"), body: result, }); } @@ -98,11 +97,11 @@ export class eWalletButton extends Component { } _getText(orderTotal, eWalletPrograms, eWalletRewards) { if (orderTotal < 0 && eWalletPrograms.length >= 1) { - return this.env._t("eWallet Refund"); + return _t("eWallet Refund"); } else if (eWalletRewards.length >= 1) { - return this.env._t("eWallet Pay"); + return _t("eWallet Pay"); } else { - return this.env._t("eWallet"); + return _t("eWallet"); } } } diff --git a/addons/pos_loyalty/static/src/app/control_buttons/promo_code_button/promo_code_button.js b/addons/pos_loyalty/static/src/app/control_buttons/promo_code_button/promo_code_button.js index a41a2be740d..d3b497d0124 100644 --- a/addons/pos_loyalty/static/src/app/control_buttons/promo_code_button/promo_code_button.js +++ b/addons/pos_loyalty/static/src/app/control_buttons/promo_code_button/promo_code_button.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { TextInputPopup } from "@point_of_sale/app/utils/input_popups/text_input_popup"; @@ -16,9 +17,9 @@ export class PromoCodeButton extends Component { async click() { let { confirmed, payload: code } = await this.popup.add(TextInputPopup, { - title: this.env._t("Enter Code"), + title: _t("Enter Code"), startingValue: "", - placeholder: this.env._t("Gift card or Discount code"), + placeholder: _t("Gift card or Discount code"), }); if (confirmed) { code = code.trim(); diff --git a/addons/pos_loyalty/static/src/app/control_buttons/reward_button/reward_button.js b/addons/pos_loyalty/static/src/app/control_buttons/reward_button/reward_button.js index 68a46559c73..929a8f7ee99 100644 --- a/addons/pos_loyalty/static/src/app/control_buttons/reward_button/reward_button.js +++ b/addons/pos_loyalty/static/src/app/control_buttons/reward_button/reward_button.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { SelectionPopup } from "@point_of_sale/app/utils/input_popups/selection_popup"; @@ -72,7 +73,7 @@ export class RewardButton extends Component { item: product_id, })); const { confirmed, payload: selectedProduct } = await this.popup.add(SelectionPopup, { - title: this.env._t("Please select a product for this reward"), + title: _t("Please select a product for this reward"), list: productsList, }); if (!confirmed) { @@ -107,7 +108,7 @@ export class RewardButton extends Component { item: reward, })); const { confirmed, payload: selectedReward } = await this.popup.add(SelectionPopup, { - title: this.env._t("Please select a reward"), + title: _t("Please select a reward"), list: rewardsList, }); if (confirmed) { diff --git a/addons/pos_loyalty/static/src/overrides/components/partner_line/partner_line.js b/addons/pos_loyalty/static/src/overrides/components/partner_line/partner_line.js index 99454479874..ab9fde792ed 100644 --- a/addons/pos_loyalty/static/src/overrides/components/partner_line/partner_line.js +++ b/addons/pos_loyalty/static/src/overrides/components/partner_line/partner_line.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { usePos } from "@point_of_sale/app/store/pos_hook"; import { PartnerLine } from "@point_of_sale/app/screens/partner_list/partner_line/partner_line"; import { patch } from "@web/core/utils/patch"; @@ -19,6 +20,6 @@ patch(PartnerLine.prototype, { if (program.portal_visible) { return `${balanceRepr} ${program.portal_point_name}`; } - return this.env._t("%s Points", balanceRepr); + return _t("%s Points", balanceRepr); }, }); diff --git a/addons/pos_loyalty/static/src/overrides/components/payment_screen/payment_screen.js b/addons/pos_loyalty/static/src/overrides/components/payment_screen/payment_screen.js index 80c9660942f..5e9fff9c058 100644 --- a/addons/pos_loyalty/static/src/overrides/components/payment_screen/payment_screen.js +++ b/addons/pos_loyalty/static/src/overrides/components/payment_screen/payment_screen.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen"; import { patch } from "@web/core/utils/patch"; import { PosLoyaltyCard } from "@pos_loyalty/overrides/models/loyalty"; @@ -61,7 +62,7 @@ patch(PaymentScreen.prototype, { } if (!successful) { this.popup.add(ErrorPopup, { - title: this.env._t("Error validating rewards"), + title: _t("Error validating rewards"), body: payload.message, }); return; diff --git a/addons/pos_loyalty/static/src/overrides/components/product_screen/product_screen.js b/addons/pos_loyalty/static/src/overrides/components/product_screen/product_screen.js index cb9794b5b2b..a5affdf6e68 100644 --- a/addons/pos_loyalty/static/src/overrides/components/product_screen/product_screen.js +++ b/addons/pos_loyalty/static/src/overrides/components/product_screen/product_screen.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useBarcodeReader } from "@point_of_sale/app/barcode/barcode_reader_hook"; import { patch } from "@web/core/utils/patch"; @@ -25,9 +26,7 @@ patch(ProductScreen.prototype, { // Do not allow negative quantity or price in a gift card or ewallet orderline. // Refunding gift card or ewallet is not supported. this.notification.add( - this.env._t( - "You cannot set negative quantity or price to gift card or ewallet." - ), + _t("You cannot set negative quantity or price to gift card or ewallet."), 4000 ); return; @@ -41,13 +40,13 @@ patch(ProductScreen.prototype, { ) { const reward = this.pos.reward_by_id[selectedLine.reward_id]; const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Deactivating reward"), - body: this.env._t( + title: _t("Deactivating reward"), + body: _t( "Are you sure you want to remove %s from this order?\n You will still be able to claim it through the reward button.", reward.description ), - cancelText: this.env._t("No"), - confirmText: this.env._t("Yes"), + cancelText: _t("No"), + confirmText: _t("Yes"), }); if (confirmed) { buffer = null; diff --git a/addons/pos_loyalty/static/src/overrides/components/ticket_screen/ticket_screen.js b/addons/pos_loyalty/static/src/overrides/components/ticket_screen/ticket_screen.js index 3d3437e248a..eb69eb5ec78 100644 --- a/addons/pos_loyalty/static/src/overrides/components/ticket_screen/ticket_screen.js +++ b/addons/pos_loyalty/static/src/overrides/components/ticket_screen/ticket_screen.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; import { useService } from "@web/core/utils/hooks"; import { patch } from "@web/core/utils/patch"; @@ -36,7 +37,7 @@ patch(TicketScreen.prototype, { }, _showNotAllowedRefundNotification() { this.notification.add( - this.env._t( + _t( "Refunding a top up or reward product for an eWallet or gift card program is not allowed." ), 5000 diff --git a/addons/pos_mercury/static/src/overrides/components/payment_screen/payment_screen.js b/addons/pos_mercury/static/src/overrides/components/payment_screen/payment_screen.js index 06c3c4da9a5..f348c9acf0f 100644 --- a/addons/pos_mercury/static/src/overrides/components/payment_screen/payment_screen.js +++ b/addons/pos_mercury/static/src/overrides/components/payment_screen/payment_screen.js @@ -178,9 +178,9 @@ patch(PaymentScreen.prototype, { response.message; } else { if (can_connect_to_server) { - message = self.env._t("No response from Vantiv (Vantiv down?)"); + message = _t("No response from Vantiv (Vantiv down?)"); } else { - message = self.env._t("No response from server (connected to network?)"); + message = _t("No response from server (connected to network?)"); } } def.resolve({ @@ -194,8 +194,8 @@ patch(PaymentScreen.prototype, { const order = this.pos.get_order(); if (order.get_due(order.selected_paymentline) < 0) { this.popup.add(ErrorPopup, { - title: this.env._t("Refunds not supported"), - body: this.env._t( + title: _t("Refunds not supported"), + body: _t( "Credit card refunds are not supported. Instead select your credit card payment method, click 'Validate' and refund the original charge manually through the Vantiv backend." ), }); @@ -210,8 +210,8 @@ patch(PaymentScreen.prototype, { if (!decodedMagtek) { this.popup.add(ErrorPopup, { - title: this.env._t("Could not read card"), - body: this.env._t( + title: _t("Could not read card"), + body: _t( "This can be caused by a badly executed swipe or by not having your keyboard layout set to US QWERTY (not US International)." ), }); @@ -248,7 +248,7 @@ patch(PaymentScreen.prototype, { transaction: def, }); def.notify({ - message: this.env._t("Handling transaction..."), + message: _t("Handling transaction..."), }); } // FIXME POSREF timeout @@ -270,14 +270,14 @@ patch(PaymentScreen.prototype, { if (data === "not setup") { def.resolve({ - message: this.env._t("Please setup your Vantiv merchant account."), + message: _t("Please setup your Vantiv merchant account."), }); return; } if (data === "internal error") { def.resolve({ - message: this.env._t("Odoo error while processing transaction."), + message: _t("Odoo error while processing transaction."), }); return; } @@ -330,7 +330,7 @@ patch(PaymentScreen.prototype, { if (response.message === "PARTIAL AP") { def.resolve({ - message: this.env._t("Partially approved"), + message: _t("Partially approved"), auto_close: false, }); } else { @@ -393,7 +393,7 @@ patch(PaymentScreen.prototype, { })); this.popup .add(SelectionPopup, { - title: this.env._t("Pay with: "), + title: _t("Pay with: "), list: selectionList, }) .then(({ confirmed, payload: selectedPaymentMethod }) => { @@ -433,10 +433,10 @@ patch(PaymentScreen.prototype, { var rpc_method = ""; if (is_voidsale) { - message = this.env._t("Reversal failed, sending VoidSale..."); + message = _t("Reversal failed, sending VoidSale..."); rpc_method = "do_voidsale"; } else { - message = this.env._t("Sending reversal..."); + message = _t("Sending reversal..."); rpc_method = "do_reversal"; } @@ -461,7 +461,7 @@ patch(PaymentScreen.prototype, { if (data === "internal error") { def.resolve({ - message: self.env._t("Odoo error while processing transaction."), + message: _t("Odoo error while processing transaction."), }); return; } @@ -475,7 +475,7 @@ patch(PaymentScreen.prototype, { } else { // reversal was successful def.resolve({ - message: self.env._t("Reversal succeeded"), + message: _t("Reversal succeeded"), }); self.remove_paymentline_by_ref(line); @@ -484,7 +484,7 @@ patch(PaymentScreen.prototype, { // voidsale ended, nothing more we can do if (response.status === "Approved") { def.resolve({ - message: self.env._t("VoidSale succeeded"), + message: _t("VoidSale succeeded"), }); self.remove_paymentline_by_ref(line); diff --git a/addons/pos_mercury/static/src/overrides/components/product_screen/product_screen.js b/addons/pos_mercury/static/src/overrides/components/product_screen/product_screen.js index aa67b0bad9a..8c3493cc851 100644 --- a/addons/pos_mercury/static/src/overrides/components/product_screen/product_screen.js +++ b/addons/pos_mercury/static/src/overrides/components/product_screen/product_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useBarcodeReader } from "@point_of_sale/app/barcode/barcode_reader_hook"; import { patch } from "@web/core/utils/patch"; @@ -14,7 +15,7 @@ patch(ProductScreen.prototype, { }, credit_error_action() { this.popup.add(ErrorPopup, { - body: this.env._t("Go to payment screen to use cards"), + body: _t("Go to payment screen to use cards"), }); }, }); diff --git a/addons/pos_online_payment/static/src/app/screens/payment_screen/payment_screen.js b/addons/pos_online_payment/static/src/app/screens/payment_screen/payment_screen.js index b03117221da..229c31f656d 100644 --- a/addons/pos_online_payment/static/src/app/screens/payment_screen/payment_screen.js +++ b/addons/pos_online_payment/static/src/app/screens/payment_screen/payment_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen"; import { patch } from "@web/core/utils/patch"; import { OnlinePaymentPopup } from "@pos_online_payment/app/utils/online_payment_popup/online_payment_popup"; @@ -21,8 +22,8 @@ patch(PaymentScreen.prototype, { amount = line.get_amount(); if (amount <= 0) { this.popup.add(ErrorPopup, { - title: this.env._t("Invalid online payment"), - body: this.env._t( + title: _t("Invalid online payment"), + body: _t( "Online payments cannot have a negative amount (%s: %s).", line.payment_method.name, this.env.utils.formatCurrency(amount) @@ -34,8 +35,8 @@ patch(PaymentScreen.prototype, { } if (!floatIsZero(unpaidAmount - remainingAmount, this.pos.currency.decimal_places)) { this.popup.add(ErrorPopup, { - title: this.env._t("Invalid online payments"), - body: this.env._t( + title: _t("Invalid online payments"), + body: _t( "The total amount of remaining online payments to execute (%s) doesn't correspond to the remaining unpaid amount of the order (%s).", this.env.utils.formatCurrency(remainingAmount), this.env.utils.formatCurrency(unpaidAmount) @@ -99,8 +100,8 @@ patch(PaymentScreen.prototype, { if (!qrCodeData || qrCodeData.length == 0) { this.cancelOnlinePayment(this.currentOrder); this.popup.add(ErrorPopup, { - title: this.env._t("Online payment unavailable"), - body: this.env._t("The QR Code for paying could not be generated."), + title: _t("Online payment unavailable"), + body: _t("The QR Code for paying could not be generated."), }); return false; } @@ -113,8 +114,8 @@ patch(PaymentScreen.prototype, { lastOrderServerOPData = await this.currentOrder.update_online_payments_data_with_server(this.pos.orm, onlinePaymentLineAmount); if (!lastOrderServerOPData) { this.popup.add(ErrorPopup, { - title: this.env._t("Online payment unavailable"), - body: this.env._t("There is a problem with the server. The order online payment status cannot be retrieved."), + title: _t("Online payment unavailable"), + body: _t("There is a problem with the server. The order online payment status cannot be retrieved."), }); return false; } @@ -152,9 +153,9 @@ patch(PaymentScreen.prototype, { const orderServerOPData = await this.currentOrder.update_online_payments_data_with_server(this.pos.orm, 0); if (!orderServerOPData) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Online payment unavailable"), - body: this.env._t("There is a problem with the server. The order online payment status cannot be retrieved. Are you sure there is no online payment for this order ?"), - confirmText: this.env._t("Yes"), + title: _t("Online payment unavailable"), + body: _t("There is a problem with the server. The order online payment status cannot be retrieved. Are you sure there is no online payment for this order ?"), + confirmText: _t("Yes"), }); if (!confirmed) { return false; @@ -178,14 +179,14 @@ patch(PaymentScreen.prototype, { }, showSaveOrderOnServerErrorPopup() { this.popup.add(ErrorPopup, { - title: this.env._t("Online payment unavailable"), - body: this.env._t("There is a problem with the server. The order cannot be saved and therefore the online payment is not possible."), + title: _t("Online payment unavailable"), + body: _t("There is a problem with the server. The order cannot be saved and therefore the online payment is not possible."), }); }, showModifiedOnlinePaymentsPopup() { this.popup.add(ErrorPopup, { - title: this.env._t("Updated online payments"), - body: this.env._t("There are online payments that were missing in your view."), + title: _t("Updated online payments"), + body: _t("There are online payments that were missing in your view."), }); }, async showOnlinePaymentQrCode(qrCodeData, amount) { @@ -212,8 +213,8 @@ patch(PaymentScreen.prototype, { async afterPaidOrderSavedOnServer(orderJSON) { if (!orderJSON) { this.popup.add(ErrorPopup, { - title: this.env._t("Server error"), - body: this.env._t("The saved order could not be retrieved."), + title: _t("Server error"), + body: _t("The saved order could not be retrieved."), }); return; } @@ -232,8 +233,8 @@ patch(PaymentScreen.prototype, { const updatedOrder = this.pos.createReactiveOrder(orderJSON); if (!updatedOrder || this.currentOrder.server_id !== updatedOrder.backendId) { this.popup.add(ErrorPopup, { - title: this.env._t("Order saving issue"), - body: this.env._t("The order has not been saved correctly on the server."), + title: _t("Order saving issue"), + body: _t("The order has not been saved correctly on the server."), }); return; } @@ -253,8 +254,8 @@ patch(PaymentScreen.prototype, { if (isInvoiceRequested) { if (!this.currentOrder.account_move) { this.popup.add(ErrorPopup, { - title: this.env._t("Invoice could not be generated"), - body: this.env._t("The invoice could not be generated."), + title: _t("Invoice could not be generated"), + body: _t("The invoice could not be generated."), }); } else { await this.report.download("account.account_invoices", [ diff --git a/addons/pos_restaurant/static/src/app/control_buttons/orderline_note_button/orderline_note_button.js b/addons/pos_restaurant/static/src/app/control_buttons/orderline_note_button/orderline_note_button.js index 5160cca18f2..31e7d0009d9 100644 --- a/addons/pos_restaurant/static/src/app/control_buttons/orderline_note_button/orderline_note_button.js +++ b/addons/pos_restaurant/static/src/app/control_buttons/orderline_note_button/orderline_note_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { TextAreaPopup } from "@point_of_sale/app/utils/input_popups/textarea_popup"; @@ -23,7 +24,7 @@ export class OrderlineNoteButton extends Component { const { confirmed, payload: inputNote } = await this.popup.add(TextAreaPopup, { startingValue: this.selectedOrderline.getNote(), - title: this.env._t("Add internal Note"), + title: _t("Add internal Note"), }); if (confirmed) { diff --git a/addons/pos_restaurant/static/src/app/control_buttons/table_guests_button/table_guests_button.js b/addons/pos_restaurant/static/src/app/control_buttons/table_guests_button/table_guests_button.js index ebb513ab1f3..0c71dcaff27 100644 --- a/addons/pos_restaurant/static/src/app/control_buttons/table_guests_button/table_guests_button.js +++ b/addons/pos_restaurant/static/src/app/control_buttons/table_guests_button/table_guests_button.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; import { useService } from "@web/core/utils/hooks"; import { NumberPopup } from "@point_of_sale/app/utils/input_popups/number_popup"; @@ -24,7 +25,7 @@ export class TableGuestsButton extends Component { const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, { startingValue: this.nGuests, cheap: true, - title: this.env._t("Guests?"), + title: _t("Guests?"), isInputSelected: true, }); @@ -34,8 +35,8 @@ export class TableGuestsButton extends Component { const max_capacity = 2 ** 31 - 1; if (guestCount > max_capacity) { await this.popup.add(ErrorPopup, { - title: this.env._t("Blocked action"), - body: this.env._t("You cannot put a number that exceeds %s ", max_capacity), + title: _t("Blocked action"), + body: _t("You cannot put a number that exceeds %s ", max_capacity), }); return; } diff --git a/addons/pos_restaurant/static/src/app/floor_screen/floor_screen.js b/addons/pos_restaurant/static/src/app/floor_screen/floor_screen.js index 6ca2a2c2d36..8e4fcbce070 100644 --- a/addons/pos_restaurant/static/src/app/floor_screen/floor_screen.js +++ b/addons/pos_restaurant/static/src/app/floor_screen/floor_screen.js @@ -1,5 +1,7 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; +import { sprintf } from "@web/core/utils/strings"; import { ConnectionLostError } from "@web/core/network/rpc_service"; import { debounce } from "@web/core/utils/timing"; import { registry } from "@web/core/registry"; @@ -378,8 +380,8 @@ export class FloorScreen extends Component { } async addFloor() { const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, { - title: this.env._t("New Floor"), - placeholder: this.env._t("Floor name"), + title: _t("New Floor"), + placeholder: _t("Floor name"), }); if (!confirmed) { return; @@ -441,7 +443,7 @@ export class FloorScreen extends Component { if (selectedTables.length == 0) { const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, { startingValue: selectedFloor.name, - title: this.env._t("Floor Name ?"), + title: _t("Floor Name ?"), }); if (!confirmed) { return; @@ -455,7 +457,7 @@ export class FloorScreen extends Component { const selectedTable = selectedTables[0]; const { confirmed, payload: newName } = await this.popup.add(TextInputPopup, { startingValue: selectedTable.name, - title: this.env._t("Table Name?"), + title: _t("Table Name?"), }); if (!confirmed) { return; @@ -473,7 +475,7 @@ export class FloorScreen extends Component { const { confirmed, payload: inputNumber } = await this.popup.add(NumberPopup, { startingValue: 0, cheap: true, - title: this.env._t("Number of Seats?"), + title: _t("Number of Seats?"), isInputSelected: true, }); if (!confirmed) { @@ -525,8 +527,8 @@ export class FloorScreen extends Component { if (this.selectedTables.length == 0) { const { confirmed } = await this.popup.add(ConfirmPopup, { title: `Removing floor ${this.activeFloor.name}`, - body: this.env._t( - "Removing a floor cannot be undone. Do you still want to remove %s?", + body: sprintf( + _t("Removing a floor cannot be undone. Do you still want to remove %s?"), this.activeFloor.name ), }); @@ -563,8 +565,8 @@ export class FloorScreen extends Component { return; } const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Are you sure?"), - body: this.env._t("Removing a table cannot be undone"), + title: _t("Are you sure?"), + body: _t("Removing a table cannot be undone"), }); if (!confirmed) { return; @@ -587,8 +589,8 @@ export class FloorScreen extends Component { delete this.pos.tables_by_id[id]; } else { await this.popup.add(ErrorPopup, { - title: this.env._t("Delete Error"), - body: this.env._t( + title: _t("Delete Error"), + body: _t( "You cannot delete a table with orders still in draft for this table." ), }); diff --git a/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js b/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js index 150fe91bfd1..5ad7c8612b9 100644 --- a/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js +++ b/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { parseFloat } from "@web/views/fields/parsers"; import { renderToElement } from "@web/core/utils/render"; import { registry } from "@web/core/registry"; @@ -51,8 +52,8 @@ export class TipScreen extends Component { if (!serverId) { this.popup.add(ErrorPopup, { - title: this.env._t("Unsynced order"), - body: this.env._t( + title: _t("Unsynced order"), + body: _t( "This order is not yet synced to server. Make sure it is synced then try again." ), }); @@ -143,8 +144,8 @@ export class TipScreen extends Component { window.print(); } catch { await this.popup.add(ErrorPopup, { - title: this.env._t("Printing is not supported on some browsers"), - body: this.env._t( + title: _t("Printing is not supported on some browsers"), + body: _t( "Printing is not supported on some browsers due to no default printing protocol " + "is available. It is possible to print your tickets by making use of an IoT Box." ), diff --git a/addons/pos_restaurant/static/src/overrides/components/ticket_screen/ticket_screen.js b/addons/pos_restaurant/static/src/overrides/components/ticket_screen/ticket_screen.js index 4232f4cda02..d2f2452fc50 100644 --- a/addons/pos_restaurant/static/src/overrides/components/ticket_screen/ticket_screen.js +++ b/addons/pos_restaurant/static/src/overrides/components/ticket_screen/ticket_screen.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; import { useAutofocus } from "@web/core/utils/hooks"; import { patch } from "@web/core/utils/patch"; @@ -36,7 +38,7 @@ patch(TicketScreen.prototype, { return Object.assign({}, super._getSearchFields(...arguments), { TABLE: { repr: this.getTable.bind(this), - displayName: this.env._t("Table"), + displayName: _t("Table"), modelField: "table_id.name", }, }); @@ -118,8 +120,8 @@ patch(TicketScreen.prototype, { const result = super._getOrderStates(...arguments); if (this.pos.config.set_tip_after_payment) { result.delete("PAYMENT"); - result.set("OPEN", { text: this.env._t("Open"), indented: true }); - result.set("TIPPING", { text: this.env._t("Tipping"), indented: true }); + result.set("OPEN", { text: _t("Open"), indented: true }); + result.set("TIPPING", { text: _t("Tipping"), indented: true }); } return result; }, diff --git a/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js b/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js index ff0663759c6..20ee787f496 100644 --- a/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js +++ b/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { sprintf } from "@web/core/utils/strings"; import { parseFloat } from "@web/views/fields/parsers"; import { useBus, useService } from "@web/core/utils/hooks"; @@ -92,17 +93,17 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { } async onClickSaleOrder(clickedOrder) { const { confirmed, payload: selectedOption } = await this.popup.add(SelectionPopup, { - title: this.env._t("What do you want to do?"), + title: _t("What do you want to do?"), list: [ - { id: "0", label: this.env._t("Settle the order"), item: "settle" }, + { id: "0", label: _t("Settle the order"), item: "settle" }, { id: "1", - label: this.env._t("Apply a down payment (percentage)"), + label: _t("Apply a down payment (percentage)"), item: "dpPercentage", }, { id: "2", - label: this.env._t("Apply a down payment (fixed amount)"), + label: _t("Apply a down payment (fixed amount)"), item: "dpAmount", }, ], @@ -124,7 +125,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { getId(linkedSO.partner_shipping_id) !== getId(sale_order.partner_shipping_id) ) { currentPOSOrder = this.pos.add_new_order(); - this.notification.add(this.env._t("A new order has been created."), 4000); + this.notification.add(_t("A new order has been created."), 4000); } } @@ -140,8 +141,8 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { try { await this.pos._loadPartners([sale_order.partner_id[0]]); } catch { - const title = this.env._t("Customer loading error"); - const body = this.env._t( + const title = _t("Customer loading error"); + const body = _t( "There was a problem in loading the %s customer.", sale_order.partner_id[1] ); @@ -176,12 +177,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { .map((line) => line.product_id[0]); if (product_to_add_in_pos.length) { const { confirmed } = await this.popup.add(ConfirmPopup, { - title: this.env._t("Products not available in POS"), - body: this.env._t( + title: _t("Products not available in POS"), + body: _t( "Some of the products in your Sale Order are not available in POS, do you want to import them?" ), - confirmText: this.env._t("Yes"), - cancelText: this.env._t("No"), + confirmText: _t("Yes"), + cancelText: _t("No"), }); if (confirmed) { await this.pos._addProducts(product_to_add_in_pos); @@ -232,12 +233,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { const { confirmed } = useLoadedLots === undefined ? await this.popup.add(ConfirmPopup, { - title: this.env._t("SN/Lots Loading"), - body: this.env._t( + title: _t("SN/Lots Loading"), + body: _t( "Do you want to load the SN/Lots linked to the Sales Order?" ), - confirmText: this.env._t("Yes"), - cancelText: this.env._t("No"), + confirmText: _t("Yes"), + cancelText: _t("No"), }) : { confirmed: useLoadedLots }; useLoadedLots = confirmed; @@ -271,9 +272,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { this.pos.config.down_payment_product_id[0] ); if (!down_payment_product) { - await this.pos._addProducts([ - this.pos.config.down_payment_product_id[0], - ]); + await this.pos._addProducts([this.pos.config.down_payment_product_id[0]]); down_payment_product = this.pos.db.get_product_by_id( this.pos.config.down_payment_product_id[0] ); @@ -293,12 +292,12 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { let popupInputSuffix = ""; const popupTotalDue = sale_order.amount_total; let getInputBufferReminder = () => false; - const popupSubtitle = this.env._t("Due balance: %s"); + const popupSubtitle = _t("Due balance: %s"); if (selectedOption == "dpAmount") { - popupTitle = this.env._t("Down Payment"); + popupTitle = _t("Down Payment"); popupInputSuffix = this.pos.currency.symbol; } else { - popupTitle = this.env._t("Down Payment"); + popupTitle = _t("Down Payment"); popupInputSuffix = "%"; getInputBufferReminder = (buffer) => { if (buffer && buffer.length > 0) { @@ -335,7 +334,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { } if (down_payment > sale_order.amount_unpaid) { - const errorBody = this.env._t( + const errorBody = _t( "You have tried to charge a down payment of %s but only %s remains to be paid, %s will be applied to the purchase order line.", this.env.utils.formatCurrency(down_payment), this.env.utils.formatCurrency(sale_order.amount_unpaid), @@ -365,8 +364,8 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { new_line.set_unit_price(down_payment); this.pos.get_order().add_orderline(new_line); } else { - const title = this.env._t("No down payment product"); - const body = this.env._t( + const title = _t("No down payment product"); + const body = _t( "It seems that you didn't configure a down payment product in your point of sale.\ You can go to your point of sale configuration to choose one." ); diff --git a/addons/pos_sale/static/src/app/order_management_screen/sale_order_row/sale_order_row.js b/addons/pos_sale/static/src/app/order_management_screen/sale_order_row/sale_order_row.js index 5dc991bd83a..1dcf4cd8e1c 100644 --- a/addons/pos_sale/static/src/app/order_management_screen/sale_order_row/sale_order_row.js +++ b/addons/pos_sale/static/src/app/order_management_screen/sale_order_row/sale_order_row.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { Component, useState } from "@odoo/owl"; import { useService } from "@web/core/utils/hooks"; import { deserializeDateTime } from "@web/core/l10n/dates"; @@ -52,11 +54,11 @@ export class SaleOrderRow extends Component { } get state() { const state_mapping = { - draft: this.env._t("Quotation"), - sent: this.env._t("Quotation Sent"), - sale: this.env._t("Sales Order"), - done: this.env._t("Locked"), - cancel: this.env._t("Cancelled"), + draft: _t("Quotation"), + sent: _t("Quotation Sent"), + sale: _t("Sales Order"), + done: _t("Locked"), + cancel: _t("Cancelled"), }; return state_mapping[this.order.state]; diff --git a/addons/pos_self_order/static/src/pages/product_main_view/product_main_view.js b/addons/pos_self_order/static/src/pages/product_main_view/product_main_view.js index a3bf4b369b3..aa1b38e0909 100644 --- a/addons/pos_self_order/static/src/pages/product_main_view/product_main_view.js +++ b/addons/pos_self_order/static/src/pages/product_main_view/product_main_view.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component, onWillUnmount, useState } from "@odoo/owl"; import { useSelfOrder } from "@pos_self_order/self_order_service"; import { NavBar } from "@pos_self_order/components/navbar/navbar"; @@ -90,7 +91,7 @@ export class ProductMainView extends Component { if (!increase && sentQty === currentQty) { this.selfOrder.notification.add( - this.env._t( + _t( "You cannot reduce the quantity of an order that has already been sent!" ), { type: "danger" } diff --git a/addons/product/static/src/js/pricelist_report/product_pricelist_report.js b/addons/product/static/src/js/pricelist_report/product_pricelist_report.js index 815390d33b7..db62e7c03c4 100644 --- a/addons/product/static/src/js/pricelist_report/product_pricelist_report.js +++ b/addons/product/static/src/js/pricelist_report/product_pricelist_report.js @@ -1,6 +1,6 @@ /** @odoo-module **/ - +import { _t } from "@web/core/l10n/translation"; import { Component, markup, onRendered, onWillStart, useState } from "@odoo/owl"; import { Layout } from "@web/search/layout"; import { registry } from "@web/core/registry"; @@ -46,7 +46,7 @@ export class ProductPricelistReport extends Component { }); onRendered(() => { - this.env.config.setDisplayName(this.env._t("Pricelist Report")); + this.env.config.setDisplayName(_t("Pricelist Report")); }); /* @@ -122,7 +122,7 @@ export class ProductPricelistReport extends Component { ev.preventDefault(); // avoid automatic reloading of the page if (this.quantities.length >= this.MAX_QTY) { - let message = this.env._t( + let message = _t( "At most %s quantities can be displayed simultaneously. Remove a selected quantity to add others.", this.MAX_QTY ); @@ -138,12 +138,12 @@ export class ProductPricelistReport extends Component { this.quantities = this.quantities.sort((a, b) => a - b); this.renderHtml(); } else { - let message = this.env._t("Quantity already present (%s).", qty); + let message = _t("Quantity already present (%s).", qty); await this.action.doAction(sendCustomNotification("info", message)); } } else { await this.action.doAction( - sendCustomNotification("info", this.env._t("Please enter a positive whole number.")) + sendCustomNotification("info", _t("Please enter a positive whole number.")) ); } } @@ -179,7 +179,7 @@ export class ProductPricelistReport extends Component { async onClickRemoveQty(ev) { if (this.quantities.length <= 1) { await this.action.doAction( - sendCustomNotification("warning", this.env._t("You must leave at least one quantity.")) + sendCustomNotification("warning", _t("You must leave at least one quantity.")) ); return; } diff --git a/addons/product_matrix/static/src/js/product_matrix_dialog.js b/addons/product_matrix/static/src/js/product_matrix_dialog.js index a57ab1df3a0..e555f0749e3 100644 --- a/addons/product_matrix/static/src/js/product_matrix_dialog.js +++ b/addons/product_matrix/static/src/js/product_matrix_dialog.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dialog } from '@web/core/dialog/dialog'; import { formatMonetary } from "@web/views/fields/formatters"; import { useHotkey } from "@web/core/hotkeys/hotkey_hook"; @@ -9,7 +10,7 @@ const { Component, onMounted, markup, useRef } = owl; export class ProductMatrixDialog extends Component { setup() { this.size = 'xl'; - this.title = this.env._t("Choose Product Variants"); + this.title = _t("Choose Product Variants"); const productMatrixRef = useRef('productMatrix'); useHotkey("enter", () => this._onConfirm(), { diff --git a/addons/project/static/src/components/project_many2one_field/project_many2one_field.js b/addons/project/static/src/components/project_many2one_field/project_many2one_field.js index 95365f9b653..3097d49a245 100644 --- a/addons/project/static/src/components/project_many2one_field/project_many2one_field.js +++ b/addons/project/static/src/components/project_many2one_field/project_many2one_field.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from '@web/core/registry'; import { Many2OneField, many2OneField } from '@web/views/fields/many2one/many2one_field'; @@ -8,7 +9,7 @@ export class ProjectMany2OneField extends Many2OneField { const props = super.Many2XAutocompleteProps; const { project_id, parent_id } = this.props.record.data; if (!project_id && !parent_id) { - props.placeholder = this.env._t("Private"); + props.placeholder = _t("Private"); } return props; } diff --git a/addons/project/static/src/components/project_right_side_panel/components/project_milestone.js b/addons/project/static/src/components/project_right_side_panel/components/project_milestone.js index dc728f0aa5b..3d27d236fc8 100644 --- a/addons/project/static/src/components/project_right_side_panel/components/project_milestone.js +++ b/addons/project/static/src/components/project_right_side_panel/components/project_milestone.js @@ -3,6 +3,7 @@ import { formatDate } from "@web/core/l10n/dates"; import { useService } from '@web/core/utils/hooks'; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; +import { _t } from "@web/core/l10n/translation"; const { Component, useState, onWillUpdateProps, status } = owl; const { DateTime } = luxon; @@ -49,7 +50,7 @@ export class ProjectMilestone extends Component { async onDeleteMilestone() { this.dialog.add(ConfirmationDialog, { - body: this.env._t("Are you sure you want to delete this record?"), + body: _t("Are you sure you want to delete this record?"), confirm: async () => { await this.orm.call('project.milestone', 'unlink', [this.milestone.id]); await this.props.load(); @@ -64,7 +65,7 @@ export class ProjectMilestone extends Component { this.props.open({ resModel: this.resModel, resId: this.milestone.id, - title: this.env._t("Milestone"), + title: _t("Milestone"), }, { onClose: async () => { if (status(this) === "mounted") { diff --git a/addons/project/static/src/components/project_right_side_panel/project_right_side_panel.js b/addons/project/static/src/components/project_right_side_panel/project_right_side_panel.js index c5e86403cd1..38e05fb6de9 100644 --- a/addons/project/static/src/components/project_right_side_panel/project_right_side_panel.js +++ b/addons/project/static/src/components/project_right_side_panel/project_right_side_panel.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { formatFloat } from '@web/views/fields/formatters'; import { ViewButton } from '@web/views/view_button/view_button'; @@ -52,8 +53,8 @@ export class ProjectRightSidePanel extends Component { get sectionNames() { return { - 'milestones': this.env._t('Milestones'), - 'profitability': this.env._t('Profitability'), + 'milestones': _t('Milestones'), + 'profitability': _t('Profitability'), }; } @@ -115,7 +116,7 @@ export class ProjectRightSidePanel extends Component { }; this.openFormViewDialog({ context, - title: this.env._t('New Milestone'), + title: _t('New Milestone'), resModel: 'project.milestone', onRecordSaved: async () => { await this.loadMilestones(); diff --git a/addons/project/static/src/components/project_task_priority_switch_field/project_task_priority_switch_field.js b/addons/project/static/src/components/project_task_priority_switch_field/project_task_priority_switch_field.js index a8db88cc98d..2150f3413b2 100644 --- a/addons/project/static/src/components/project_task_priority_switch_field/project_task_priority_switch_field.js +++ b/addons/project/static/src/components/project_task_priority_switch_field/project_task_priority_switch_field.js @@ -1,12 +1,13 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { PriorityField, priorityField } from "@web/views/fields/priority/priority_field"; export class PrioritySwitchField extends PriorityField { get commands() { return this.options.map(([id, name]) => [ - this.env._t("Set priority as %s", name), + _t("Set priority as %s", name), () => this.updateRecord(id), { category: "smart_action", diff --git a/addons/project/static/src/components/project_task_state_selection/project_task_state_selection.js b/addons/project/static/src/components/project_task_state_selection/project_task_state_selection.js index 49d5732f856..992c27c3e3f 100644 --- a/addons/project/static/src/components/project_task_state_selection/project_task_state_selection.js +++ b/addons/project/static/src/components/project_task_state_selection/project_task_state_selection.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { StateSelectionField, stateSelectionField, @@ -43,7 +44,7 @@ export class ProjectTaskStateSelection extends StateSelectionField { if (this.props.viewType != 'form') { super.setup(); } else { - const commandName = this.env._t("Set state as..."); + const commandName = _t("Set state as..."); useCommand( commandName, () => { @@ -73,14 +74,14 @@ export class ProjectTaskStateSelection extends StateSelectionField { get options() { const options = [ - ["1_canceled", this.env._t("Canceled")], - ["1_done", this.env._t("Done")], + ["1_canceled", _t("Canceled")], + ["1_done", _t("Done")], ]; if (this.currentValue != "04_waiting_normal") { return [ - ["01_in_progress", this.env._t("In Progress")], - ["02_changes_requested", this.env._t("Changes Requested")], - ["03_approved", this.env._t("Approved")], + ["01_in_progress", _t("In Progress")], + ["02_changes_requested", _t("Changes Requested")], + ["03_approved", _t("Approved")], ...options, ]; } diff --git a/addons/project/static/src/components/subtask_one2many_field/subtask_list_renderer.js b/addons/project/static/src/components/subtask_one2many_field/subtask_list_renderer.js index 519a008693a..efb4c7976c9 100644 --- a/addons/project/static/src/components/subtask_one2many_field/subtask_list_renderer.js +++ b/addons/project/static/src/components/subtask_one2many_field/subtask_list_renderer.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { ListRenderer } from '@web/views/list/list_renderer'; @@ -12,7 +13,7 @@ export class SubtaskListRenderer extends ListRenderer { async onDeleteRecord(record) { this.dialog.add(ConfirmationDialog, { - body: this.env._t("Are you sure you want to delete this record?"), + body: _t("Are you sure you want to delete this record?"), confirm: () => super.onDeleteRecord(record), cancel: () => {}, }); diff --git a/addons/project/static/src/views/burndown_chart/burndown_chart_model.js b/addons/project/static/src/views/burndown_chart/burndown_chart_model.js index ec088acdb2a..0a613b8a3a8 100644 --- a/addons/project/static/src/views/burndown_chart/burndown_chart_model.js +++ b/addons/project/static/src/views/burndown_chart/burndown_chart_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { GraphModel } from "@web/views/graph/graph_model"; import { sortBy } from "@web/core/utils/arrays"; @@ -78,7 +79,7 @@ export class BurndownChartModel extends GraphModel { * @override */ async _loadDataPoints(metaData) { - metaData.measures.__count.string = this.env._t("# of Tasks"); + metaData.measures.__count.string = _t("# of Tasks"); return super._loadDataPoints(metaData); } } diff --git a/addons/project/static/src/views/burndown_chart/burndown_chart_search_model.js b/addons/project/static/src/views/burndown_chart/burndown_chart_search_model.js index 7a199af20ad..36725641e9c 100644 --- a/addons/project/static/src/views/burndown_chart/burndown_chart_search_model.js +++ b/addons/project/static/src/views/burndown_chart/burndown_chart_search_model.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { SearchModel } from "@web/search/search_model"; @@ -43,7 +44,7 @@ export class BurndownChartSearchModel extends SearchModel { deactivateGroup(groupId) { // Prevent removing Date & Stage group by from the search if (this.searchItems[this.stageIdSearchItemId].groupId == groupId && this.searchItems[this.dateSearchItemId].groupId) { - this._addGroupByNotification(this.env._t("Date and Stage")); + this._addGroupByNotification(_t("Date and Stage")); return; } super.deactivateGroup(groupId); @@ -67,7 +68,7 @@ export class BurndownChartSearchModel extends SearchModel { if (filtered_query.length !== this.query.length) { this.query = filtered_query; if (triggerNotification) { - this._addGroupByNotification(this.env._t("Date")); + this._addGroupByNotification(_t("Date")); } } } @@ -81,7 +82,7 @@ export class BurndownChartSearchModel extends SearchModel { // Ensure that stage_id is always selected. if (searchItemId === this.stageIdSearchItemId && this.query.some(queryElem => queryElem.searchItemId === searchItemId)) { - this._addGroupByNotification(this.env._t("Stage")); + this._addGroupByNotification(_t("Stage")); return; } super.toggleSearchItem(...arguments); @@ -93,7 +94,7 @@ export class BurndownChartSearchModel extends SearchModel { * @private */ _addGroupByNotification(fieldName) { - const notif = this.env._t("The Burndown Chart must be grouped by"); + const notif = _t("The Burndown Chart must be grouped by"); this.notificationService.add( `${notif} ${fieldName}`, { type: "danger" } diff --git a/addons/project/static/src/views/project_task_calendar/project_task_calendar_controller.js b/addons/project/static/src/views/project_task_calendar/project_task_calendar_controller.js index 1e3a396f7a3..21adb69c41e 100644 --- a/addons/project/static/src/views/project_task_calendar/project_task_calendar_controller.js +++ b/addons/project/static/src/views/project_task_calendar/project_task_calendar_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarController } from "@web/views/calendar/calendar_controller"; import { ProjectTaskCalendarFilterPanel } from "./project_task_calendar_filter_panel/project_task_calendar_filter_panel"; import { DeleteSubtasksConfirmationDialog } from "@project/components/delete_subtasks_confirmation_dialog/delete_subtasks_confirmation_dialog"; @@ -11,7 +12,7 @@ export class ProjectTaskCalendarController extends CalendarController { }; setup() { super.setup(...arguments); - this.env.config.setDisplayName(this.env.config.getDisplayName() + this.env._t(" - Tasks by Deadline")); + this.env.config.setDisplayName(this.env.config.getDisplayName() + _t(" - Tasks by Deadline")); } deleteRecord(record) { diff --git a/addons/project/static/src/views/project_task_calendar/project_task_calendar_model.js b/addons/project/static/src/views/project_task_calendar/project_task_calendar_model.js index 87e78a1409e..0f23bd32a9f 100644 --- a/addons/project/static/src/views/project_task_calendar/project_task_calendar_model.js +++ b/addons/project/static/src/views/project_task_calendar/project_task_calendar_model.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CalendarModel } from '@web/views/calendar/calendar_model'; export class ProjectTaskCalendarModel extends CalendarModel { @@ -9,7 +10,7 @@ export class ProjectTaskCalendarModel extends CalendarModel { get defaultFilterLabel() { this.isCheckProject = 'project_id' in this.meta.filtersInfo; if (this.isCheckProject) { - return this.env._t("Private"); + return _t("Private"); } return super.onWillStart(); } diff --git a/addons/project/static/src/views/project_task_graph/project_task_graph_model.js b/addons/project/static/src/views/project_task_graph/project_task_graph_model.js index ec076d1f69f..f0c698ffe86 100644 --- a/addons/project/static/src/views/project_task_graph/project_task_graph_model.js +++ b/addons/project/static/src/views/project_task_graph/project_task_graph_model.js @@ -1,11 +1,12 @@ /** @odoo-module **/ import { GraphModel } from "@web/views/graph/graph_model"; +import { _t } from "@web/core/l10n/translation"; export class ProjectTaskGraphModel extends GraphModel { _getDefaultFilterLabel(field) { if (field.fieldName === "project_id") { - return this.env._t("🔒 Private"); + return _t("🔒 Private"); } return super._getDefaultFilterLabel(field); } diff --git a/addons/project/static/src/views/project_task_kanban/project_task_kanban_header.js b/addons/project/static/src/views/project_task_kanban/project_task_kanban_header.js index 254879e05ed..03253c95a8a 100644 --- a/addons/project/static/src/views/project_task_kanban/project_task_kanban_header.js +++ b/addons/project/static/src/views/project_task_kanban/project_task_kanban_header.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { KanbanHeader } from "@web/views/kanban/kanban_header"; import { FormViewDialog } from "@web/views/view_dialogs/form_view_dialog"; @@ -33,7 +35,7 @@ export class ProjectTaskKanbanHeader extends KanbanHeader { context, resId: this.group.value, resModel: this.group.groupByField.relation, - title: this.env._t('Edit Personal Stage'), + title: _t('Edit Personal Stage'), onRecordSaved: async () => { await this.props.list.load(); }, @@ -67,9 +69,9 @@ export class ProjectTaskKanbanHeader extends KanbanHeader { */ _getEmptyGroupLabel(fieldName) { if (fieldName === "project_id") { - return this.env._t("🔒 Private"); + return _t("🔒 Private"); } else if (fieldName === "user_ids") { - return this.env._t("👤 Unassigned"); + return _t("👤 Unassigned"); } else { return super._getEmptyGroupLabel(fieldName); } diff --git a/addons/project/static/src/views/project_task_list/project_task_list_renderer.js b/addons/project/static/src/views/project_task_list/project_task_list_renderer.js index 84f3ac19e76..7bf118509c9 100644 --- a/addons/project/static/src/views/project_task_list/project_task_list_renderer.js +++ b/addons/project/static/src/views/project_task_list/project_task_list_renderer.js @@ -2,6 +2,7 @@ import { ListRenderer } from "@web/views/list/list_renderer"; import { getRawValue } from "@web/views/kanban/kanban_record"; +import { _t } from "@web/core/l10n/translation"; export class ProjectTaskListRenderer extends ListRenderer { isCellReadonly(column, record) { @@ -17,7 +18,6 @@ export class ProjectTaskListRenderer extends ListRenderer { } getGroupDisplayName(group) { - const { _t } = this.env; if (group.groupByField.name === "project_id" && !group.value) { return _t("🔒 Private"); } else if (group.groupByField.name === "user_ids" && !group.value) { diff --git a/addons/project/static/src/views/project_task_pivot/project_pivot_model.js b/addons/project/static/src/views/project_task_pivot/project_pivot_model.js index 3cb7b55320a..06f2b0f921f 100644 --- a/addons/project/static/src/views/project_task_pivot/project_pivot_model.js +++ b/addons/project/static/src/views/project_task_pivot/project_pivot_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { PivotModel } from "@web/views/pivot/pivot_model"; export class ProjectTaskPivotModel extends PivotModel { @@ -8,9 +9,9 @@ export class ProjectTaskPivotModel extends PivotModel { */ _getEmptyGroupLabel(fieldName) { if (fieldName === "project_id") { - return this.env._t("Private"); + return _t("Private"); } else if (fieldName === "user_ids") { - return this.env._t("Unassigned"); + return _t("Unassigned"); } else { return super._getEmptyGroupLabel(fieldName); } diff --git a/addons/project_todo/static/src/views/todo_form/todo_form_controller.js b/addons/project_todo/static/src/views/todo_form/todo_form_controller.js index 392583ea8b1..290401394ab 100644 --- a/addons/project_todo/static/src/views/todo_form/todo_form_controller.js +++ b/addons/project_todo/static/src/views/todo_form/todo_form_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { FormController } from "@web/views/form/form_controller"; import { TodoEditableBreadcrumbName } from "@project_todo/components/todo_editable_breadcrumb_name/todo_editable_breadcrumb_name"; import { TodoDoneCheckmark } from "@project_todo/components/todo_done_checkmark/todo_done_checkmark"; @@ -29,7 +30,7 @@ export class TodoFormController extends FormController { if (this.projectAccess) { filteredActions.push({ - description: this.env._t("Convert to Task"), + description: _t("Convert to Task"), callback: () => { this.model.action.doAction( "project_todo.project_task_action_convert_todo_to_task", diff --git a/addons/project_todo/static/src/web/activity/activity_menu_patch.js b/addons/project_todo/static/src/web/activity/activity_menu_patch.js index 1b9c8b7806e..0864e1eef09 100644 --- a/addons/project_todo/static/src/web/activity/activity_menu_patch.js +++ b/addons/project_todo/static/src/web/activity/activity_menu_patch.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { onExternalClick } from "@mail/utils/common/hooks"; import { ActivityMenu } from "@mail/core/web/activity_menu"; import { useEffect, useRef, useState } from "@odoo/owl"; @@ -65,7 +66,7 @@ patch(ActivityMenu.prototype, { }); document.body.click(); // hack to close dropdown this.notification.add( - this.env._t("Your to-do has been successfully added to your tasks and scheduled for completion."), + _t("Your to-do has been successfully added to your tasks and scheduled for completion."), { type: "success" }, ); this.state.addingTodo = false; diff --git a/addons/purchase_product_matrix/static/src/js/purchase_product_field.js b/addons/purchase_product_matrix/static/src/js/purchase_product_field.js index 106c68a3508..490d8eb757f 100644 --- a/addons/purchase_product_matrix/static/src/js/purchase_product_field.js +++ b/addons/purchase_product_matrix/static/src/js/purchase_product_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from '@web/core/registry'; import { Many2OneField, many2OneField } from '@web/views/fields/many2one/many2one_field'; import { ProductMatrixDialog } from "@product_matrix/js/product_matrix_dialog"; @@ -28,7 +29,7 @@ export class PurchaseOrderLineProductField extends Many2OneField { } get configurationButtonHelp() { - return this.env._t("Edit Configuration"); + return _t("Edit Configuration"); } get isConfigurableTemplate() { return this.props.record.data.is_configurable_product; diff --git a/addons/sale/static/src/js/sale_product_field.js b/addons/sale/static/src/js/sale_product_field.js index 255ae56b339..cd0856ce332 100644 --- a/addons/sale/static/src/js/sale_product_field.js +++ b/addons/sale/static/src/js/sale_product_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useEffect } from '@odoo/owl'; import { registry } from "@web/core/registry"; import { Many2OneField, many2OneField } from "@web/views/fields/many2one/many2one_field"; @@ -61,7 +62,7 @@ export class SaleOrderLineProductField extends Many2OneField { } get configurationButtonHelp() { - return this.env._t("Edit Configuration"); + return _t("Edit Configuration"); } get configurationButtonIcon() { diff --git a/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js b/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js index 2a388ece082..66c55cb7da9 100644 --- a/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js +++ b/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component, onWillStart, useState, useSubEnv } from "@odoo/owl"; import { Dialog } from '@web/core/dialog/dialog'; import { ProductList } from "../product_list/product_list"; @@ -35,7 +36,7 @@ export class ProductConfiguratorDialog extends Component { } setup() { - this.title = this.env._t("Configure"); + this.title = _t("Configure"); this.rpc = useService("rpc"); this.state = useState({ products: [], diff --git a/addons/sms/static/src/components/sms_button/sms_button.js b/addons/sms/static/src/components/sms_button/sms_button.js index 7801fd4567f..fd760f9fb29 100644 --- a/addons/sms/static/src/components/sms_button/sms_button.js +++ b/addons/sms/static/src/components/sms_button/sms_button.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; const { Component } = owl; @@ -8,7 +9,7 @@ export class SendSMSButton extends Component { setup() { this.action = useService("action"); this.user = useService("user"); - this.title = this.env._t("Send SMS Text Message"); + this.title = _t("Send SMS Text Message"); } get phoneHref() { return "sms:" + this.props.record.data[this.props.name].replace(/\s+/g, ""); diff --git a/addons/sms/static/src/components/sms_widget/fields_sms_widget.js b/addons/sms/static/src/components/sms_widget/fields_sms_widget.js index ce49339178e..833816fc131 100644 --- a/addons/sms/static/src/components/sms_widget/fields_sms_widget.js +++ b/addons/sms/static/src/components/sms_widget/fields_sms_widget.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { EmojisTextField, emojisTextField, @@ -80,7 +81,7 @@ export class SmsWidget extends EmojisTextField { var content = this.props.record.data[this.props.name] || ''; if( !content.trim().length && content.length > 0) { this.notification.add( - this.env._t("Your SMS Text Message must include at least one non-whitespace character"), + _t("Your SMS Text Message must include at least one non-whitespace character"), { type: 'danger' }, ) await this.props.record.update({ [this.props.name]: content.trim() }); diff --git a/addons/spreadsheet/static/src/assets_backend/spreadsheet_action_loader.js b/addons/spreadsheet/static/src/assets_backend/spreadsheet_action_loader.js index 138c9c3cb58..231255173c1 100644 --- a/addons/spreadsheet/static/src/assets_backend/spreadsheet_action_loader.js +++ b/addons/spreadsheet/static/src/assets_backend/spreadsheet_action_loader.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { getBundle, loadBundle } from "@web/core/assets"; import { sprintf } from "@web/core/utils/strings"; @@ -26,7 +27,7 @@ export async function loadSpreadsheetAction(env, actionName, actionLazyLoader) { actionRegistry.add( actionName, () => { - const msg = sprintf(env._t("%s couldn't be loaded"), actionName); + const msg = sprintf(_t("%s couldn't be loaded"), actionName); env.services.notification.add(msg, { type: "danger" }); }, { force: true } diff --git a/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.js b/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.js index f0d09f526c1..0aaa3a46a66 100644 --- a/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.js +++ b/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.js @@ -5,6 +5,7 @@ import { RELATIVE_DATE_RANGE_TYPES } from "@spreadsheet/helpers/constants"; import { DateFilterValue } from "../filter_date_value/filter_date_value"; import { Component } from "@odoo/owl"; +import { _t } from "@web/core/l10n/translation"; export class FilterValue extends Component { setup() { @@ -27,6 +28,10 @@ export class FilterValue extends Component { }); } + translate(text) { + return _t(text); + } + onClear(id) { this.props.model.dispatch("CLEAR_GLOBAL_FILTER_VALUE", { id }); } diff --git a/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.xml b/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.xml index 2954e804f40..9d3e13e5412 100644 --- a/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.xml +++ b/addons/spreadsheet/static/src/global_filters/components/filter_value/filter_value.xml @@ -10,12 +10,12 @@
- diff --git a/addons/spreadsheet/static/src/public_readonly_app/main.js b/addons/spreadsheet/static/src/public_readonly_app/main.js index 1be180c48dd..027490249a6 100644 --- a/addons/spreadsheet/static/src/public_readonly_app/main.js +++ b/addons/spreadsheet/static/src/public_readonly_app/main.js @@ -4,6 +4,7 @@ import { PublicReadonlySpreadsheet } from "./public_readonly"; import { setLoadXmlDefaultApp, templates } from "@web/core/assets"; import { makeEnv, startServices } from "@web/env"; import { session } from "@web/session"; +import { _t } from "@web/core/l10n/translation"; (async function boot() { odoo.info = { @@ -20,7 +21,7 @@ import { session } from "@web/session"; env, props: session.spreadsheet_public_props, templates, - translateFn: env._t, + translateFn: _t, dev: env.debug, warnIfNoStaticProps: env.debug, translatableAttributes: ["data-tooltip"], diff --git a/addons/stock/static/src/client_actions/stock_traceability_report_backend.js b/addons/stock/static/src/client_actions/stock_traceability_report_backend.js index 6d800be21e9..83e108c389c 100644 --- a/addons/stock/static/src/client_actions/stock_traceability_report_backend.js +++ b/addons/stock/static/src/client_actions/stock_traceability_report_backend.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component, onWillStart, useState } from "@odoo/owl"; import { download } from "@web/core/network/download"; import { registry } from "@web/core/registry"; @@ -104,7 +105,7 @@ export class TraceabilityReport extends Component { this.actionService.doAction({ type: "ir.actions.client", tag: "stock_report_generic", - name: this.env._t("Traceability Report"), + name: _t("Traceability Report"), context: { active_id: line.model_id, active_model: line.model, diff --git a/addons/stock/static/src/fields/stock_move_line_x2_many_field.js b/addons/stock/static/src/fields/stock_move_line_x2_many_field.js index 10ffd23ee25..bb7ec866818 100644 --- a/addons/stock/static/src/fields/stock_move_line_x2_many_field.js +++ b/addons/stock/static/src/fields/stock_move_line_x2_many_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { X2ManyField, x2ManyField } from "@web/views/fields/x2many/x2many_field"; import { useSelectCreate, useOpenMany2XRecord} from "@web/views/fields/relational_utils"; @@ -34,7 +35,7 @@ export class SMLX2ManyField extends X2ManyField { tree_view_ref: "stock.view_stock_quant_tree_simple", }; const productName = this.props.record.data.product_id[1]; - const title = this.env._t("Add line: %s", productName); + const title = _t("Add line: %s", productName); const alreadySelected = this.props.record.data.move_line_ids.records.filter((line) => line.data.quant_id?.[0]); const domain = [ ["product_id", "=", this.props.record.data.product_id[0]], diff --git a/addons/stock/static/src/stock_forecasted/forecasted_buttons.js b/addons/stock/static/src/stock_forecasted/forecasted_buttons.js index 1158155423a..98e51ab5fc0 100644 --- a/addons/stock/static/src/stock_forecasted/forecasted_buttons.js +++ b/addons/stock/static/src/stock_forecasted/forecasted_buttons.js @@ -1,4 +1,6 @@ /** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; const { Component} = owl; @@ -32,7 +34,7 @@ export class ForecastedButtons extends Component { const action = { res_model: 'product.replenish', - name: this.env._t('Product Replenish'), + name: _t('Product Replenish'), type: 'ir.actions.act_window', views: [[false, 'form']], target: 'new', diff --git a/addons/stock/static/src/stock_forecasted/stock_forecasted.js b/addons/stock/static/src/stock_forecasted/stock_forecasted.js index fec3f32eff2..b8951b04ddd 100644 --- a/addons/stock/static/src/stock_forecasted/stock_forecasted.js +++ b/addons/stock/static/src/stock_forecasted/stock_forecasted.js @@ -100,7 +100,7 @@ export class StockForecasted extends Component { } get graphInfo() { - return { noContentHelp: this.env._t("Try to add some incoming or outgoing transfers.") }; + return { noContentHelp: _t("Try to add some incoming or outgoing transfers.") }; } async openView(resModel, view, resId) { diff --git a/addons/stock/static/src/views/list/inventory_report_list_controller.js b/addons/stock/static/src/views/list/inventory_report_list_controller.js index 405d81788f6..b0d5afea371 100644 --- a/addons/stock/static/src/views/list/inventory_report_list_controller.js +++ b/addons/stock/static/src/views/list/inventory_report_list_controller.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { session } from "@web/session"; import { ListController } from "@web/views/list/list_controller"; @@ -13,8 +14,8 @@ export class InventoryReportListController extends ListController { // hack so we don't show some of the default actions when it's inappropriate to const { print, action } = actionMenus; return { - action: action.filter((a) => a.name !== this.env._t("Set")), - print: print.filter((a) => a.name !== this.env._t("Count Sheet")), + action: action.filter((a) => a.name !== _t("Set")), + print: print.filter((a) => a.name !== _t("Count Sheet")), }; } return actionMenus; diff --git a/addons/stock/static/src/views/list/inventory_report_list_model.js b/addons/stock/static/src/views/list/inventory_report_list_model.js index 6c091fdbe89..7587d5e1f88 100644 --- a/addons/stock/static/src/views/list/inventory_report_list_model.js +++ b/addons/stock/static/src/views/list/inventory_report_list_model.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { DynamicRecordList } from "@web/model/relational_model/dynamic_record_list"; import { RelationalModel } from "@web/model/relational_model/relational_model"; @@ -31,10 +32,10 @@ export class InventoryReportListModel extends RelationalModel { const justCreated = reloadedRecord.id == this._lastCreatedRecordId; if (justCreated && serverValues.create_date !== serverValues.write_date) { this.notification.add( - this.env._t( + _t( "You tried to create a record that already exists. The existing record was modified instead." ), - { title: this.env._t("This record already exists.") } + { title: _t("This record already exists.") } ); const duplicateRecords = this.root.records.filter( (record) => record.resId === reloadedRecord.resId && record.id !== reloadedRecord.id diff --git a/addons/stock_account/static/src/stock_account_forecasted/forecasted_header.js b/addons/stock_account/static/src/stock_account_forecasted/forecasted_header.js index 2064b5cc31e..db9431ca127 100644 --- a/addons/stock_account/static/src/stock_account_forecasted/forecasted_header.js +++ b/addons/stock_account/static/src/stock_account_forecasted/forecasted_header.js @@ -1,4 +1,6 @@ /** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { patch } from "@web/core/utils/patch"; import { ForecastedHeader as Parent } from "@stock/stock_forecasted/forecasted_header"; @@ -9,7 +11,7 @@ patch(Parent.prototype, { async _onClickValuation() { const context = this._getActionContext(); return this.action.doAction({ - name: this.env._t('Stock Valuation'), + name: _t('Stock Valuation'), res_model: 'stock.valuation.layer', type: 'ir.actions.act_window', view_mode: 'list,form', diff --git a/addons/survey/static/src/question_page/question_page_one2many_field.js b/addons/survey/static/src/question_page/question_page_one2many_field.js index d0d936aff86..c4b621c888a 100644 --- a/addons/survey/static/src/question_page/question_page_one2many_field.js +++ b/addons/survey/static/src/question_page/question_page_one2many_field.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { QuestionPageListRenderer } from "./question_page_list_renderer"; import { registry } from "@web/core/registry"; import { useOpenX2ManyRecord, useX2ManyCrud, X2ManyFieldDialog } from "@web/views/fields/relational_utils"; @@ -38,7 +39,7 @@ class SurveySaveError extends Error {} function SurveySaveErrorHandler(env, error, originalError) { if (originalError instanceof SurveySaveError) { env.services.notification.add(originalError.message, { - title: env._t("Validation Error"), + title: _t("Validation Error"), type: "danger", }); return true; diff --git a/addons/web/static/src/core/commands/default_providers.js b/addons/web/static/src/core/commands/default_providers.js index 7c116ea6bad..e2a18072efc 100644 --- a/addons/web/static/src/core/commands/default_providers.js +++ b/addons/web/static/src/core/commands/default_providers.js @@ -80,7 +80,7 @@ commandProviderRegistry.add("data-hotkeys", { el.placeholder || (el.innerText && `${el.innerText.slice(0, 50)}${el.innerText.length > 50 ? "..." : ""}`) || - env._t("no description provided"); + _t("no description provided"); commands.push({ Component: HotkeyCommandItem, diff --git a/addons/web/static/src/core/debug/debug_menu.js b/addons/web/static/src/core/debug/debug_menu.js index 9b9993d726e..322e9541ef1 100644 --- a/addons/web/static/src/core/debug/debug_menu.js +++ b/addons/web/static/src/core/debug/debug_menu.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { DropdownItem } from "@web/core/dropdown/dropdown_item"; import { DebugMenuBasic } from "@web/core/debug/debug_menu_basic"; @@ -13,7 +14,7 @@ export class DebugMenu extends DebugMenuBasic { const debugContext = useEnvDebugContext(); this.command = useService("command"); useCommand( - this.env._t("Debug tools..."), + _t("Debug tools..."), async () => { const items = await debugContext.getItems(this.env); let index = 0; @@ -42,8 +43,8 @@ export class DebugMenu extends DebugMenuBasic { const configByNamespace = { default: { categories: defaultCategories, - emptyMessage: this.env._t("No debug command found"), - placeholder: this.env._t("Choose a debug command..."), + emptyMessage: _t("No debug command found"), + placeholder: _t("Choose a debug command..."), }, }; const commandPaletteConfig = { diff --git a/addons/web/static/src/core/debug/debug_menu_items.js b/addons/web/static/src/core/debug/debug_menu_items.js index b01286079c9..8be16f56267 100644 --- a/addons/web/static/src/core/debug/debug_menu_items.js +++ b/addons/web/static/src/core/debug/debug_menu_items.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { routeToUrl } from "@web/core/browser/router_service"; import { registry } from "@web/core/registry"; @@ -7,7 +8,7 @@ import { registry } from "@web/core/registry"; function activateAssetsDebugging({ env }) { return { type: "item", - description: env._t("Activate Assets Debugging"), + description: _t("Activate Assets Debugging"), callback: () => { browser.location.search = "?debug=assets"; }, @@ -18,7 +19,7 @@ function activateAssetsDebugging({ env }) { function activateTestsAssetsDebugging({ env }) { return { type: "item", - description: env._t("Activate Tests Assets Debugging"), + description: _t("Activate Tests Assets Debugging"), callback: () => { browser.location.search = "?debug=assets,tests"; }, @@ -29,7 +30,7 @@ function activateTestsAssetsDebugging({ env }) { export function regenerateAssets({ env }) { return { type: "item", - description: env._t("Regenerate Assets Bundles"), + description: _t("Regenerate Assets Bundles"), callback: async () => { const domain = [ "&", @@ -50,7 +51,7 @@ function becomeSuperuser({ env }) { const becomeSuperuserURL = browser.location.origin + "/web/become"; return { type: "item", - description: env._t("Become Superuser"), + description: _t("Become Superuser"), hide: !env.services.user.isAdmin, href: becomeSuperuserURL, callback: () => { @@ -63,7 +64,7 @@ function becomeSuperuser({ env }) { function leaveDebugMode({ env }) { return { type: "item", - description: env._t("Leave the Developer Tools"), + description: _t("Leave the Developer Tools"), callback: () => { const route = env.services.router.current; route.search.debug = ""; diff --git a/addons/web/static/src/core/debug/debug_providers.js b/addons/web/static/src/core/debug/debug_providers.js index 9a347f22617..8bff7d5d895 100644 --- a/addons/web/static/src/core/debug/debug_providers.js +++ b/addons/web/static/src/core/debug/debug_providers.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "../registry"; import { browser } from "../browser/browser"; import { routeToUrl } from "../browser/router_service"; @@ -16,7 +17,7 @@ commandProviderRegistry.add("debug", { browser.location.search = "?debug=assets"; }, category: "debug", - name: env._t("Activate debug mode (with assets)"), + name: _t("Activate debug mode (with assets)"), }); } result.push({ @@ -26,7 +27,7 @@ commandProviderRegistry.add("debug", { browser.location.href = browser.location.origin + routeToUrl(route); }, category: "debug", - name: env._t("Deactivate debug mode"), + name: _t("Deactivate debug mode"), }); result.push({ action() { @@ -34,7 +35,7 @@ commandProviderRegistry.add("debug", { browser.open(runTestsURL); }, category: "debug", - name: env._t("Run JS Tests"), + name: _t("Run JS Tests"), }); result.push({ action() { @@ -42,7 +43,7 @@ commandProviderRegistry.add("debug", { browser.open(runTestsURL); }, category: "debug", - name: env._t("Run JS Mobile Tests"), + name: _t("Run JS Mobile Tests"), }); } else { if (options.searchValue.toLowerCase() === "debug") { @@ -51,7 +52,7 @@ commandProviderRegistry.add("debug", { browser.location.search = "?debug=assets"; }, category: "debug", - name: env._t("Activate debug mode (with assets)"), + name: _t("Activate debug mode (with assets)"), }); } } diff --git a/addons/web/static/src/core/domain_selector_dialog/domain_selector_dialog.js b/addons/web/static/src/core/domain_selector_dialog/domain_selector_dialog.js index 43e386e1c3d..397f1547685 100644 --- a/addons/web/static/src/core/domain_selector_dialog/domain_selector_dialog.js +++ b/addons/web/static/src/core/domain_selector_dialog/domain_selector_dialog.js @@ -1,6 +1,6 @@ /** @odoo-module **/ -import { _t } from "../l10n/translation"; +import { _t } from "@web/core/l10n/translation"; import { Component, useRef, useState } from "@odoo/owl"; import { Dialog } from "../dialog/dialog"; import { Domain } from "@web/core/domain"; @@ -71,7 +71,7 @@ export class DomainSelectorDialog extends Component { if (this.confirmButtonRef.el) { this.confirmButtonRef.el.disabled = false; } - this.notification.add(this.env._t("Domain is invalid. Please correct it"), { + this.notification.add(_t("Domain is invalid. Please correct it"), { type: "danger", }); return; diff --git a/addons/web/static/src/core/effects/effect_service.js b/addons/web/static/src/core/effects/effect_service.js index ba7a0dbcdc1..628efae02c4 100644 --- a/addons/web/static/src/core/effects/effect_service.js +++ b/addons/web/static/src/core/effects/effect_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "../registry"; import { RainbowMan } from "./rainbow_man"; @@ -45,7 +46,7 @@ function rainbowMan(env, params = {}) { ); message = message.outerHTML; } else if (!message) { - message = env._t("Well Done!"); + message = _t("Well Done!"); } if (env.services.user.showEffect) { /** @type {import("./rainbow_man").RainbowManProps} */ diff --git a/addons/web/static/src/core/errors/error_dialogs.js b/addons/web/static/src/core/errors/error_dialogs.js index 351000ac26f..ba1a8c3f042 100644 --- a/addons/web/static/src/core/errors/error_dialogs.js +++ b/addons/web/static/src/core/errors/error_dialogs.js @@ -24,9 +24,7 @@ export const standardErrorDialogProps = { export const odooExceptionTitleMap = new Map( Object.entries({ - "odoo.addons.base.models.ir_mail_server.MailDeliveryException": _t( - "MailDeliveryException" - ), + "odoo.addons.base.models.ir_mail_server.MailDeliveryException": _t("MailDeliveryException"), "odoo.exceptions.AccessDenied": _t("Access Denied"), "odoo.exceptions.MissingError": _t("Missing Record"), "odoo.exceptions.UserError": _t("User Error"), @@ -92,13 +90,13 @@ export class RPCErrorDialog extends ErrorDialog { } switch (this.props.type) { case "server": - this.title = this.env._t("Odoo Server Error"); + this.title = _t("Odoo Server Error"); break; case "script": - this.title = this.env._t("Odoo Client Error"); + this.title = _t("Odoo Client Error"); break; case "network": - this.title = this.env._t("Odoo Network Error"); + this.title = _t("Odoo Network Error"); break; } } @@ -127,7 +125,7 @@ export class WarningDialog extends Component { if (this.props.exceptionName && odooExceptionTitleMap.has(this.props.exceptionName)) { return odooExceptionTitleMap.get(this.props.exceptionName).toString(); } - return this.props.title || this.env._t("Odoo Warning"); + return this.props.title || _t("Odoo Warning"); } } WarningDialog.template = "web.WarningDialog"; @@ -145,7 +143,7 @@ export class RedirectWarningDialog extends Component { this.actionService = useService("action"); const { data, subType } = this.props; const [message, actionId, buttonText, additionalContext] = data.arguments; - this.title = capitalize(subType) || this.env._t("Odoo Warning"); + this.title = capitalize(subType) || _t("Odoo Warning"); this.message = message; this.actionId = actionId; this.buttonText = buttonText; diff --git a/addons/web/static/src/core/errors/error_handlers.js b/addons/web/static/src/core/errors/error_handlers.js index 6a4f7054cd3..ba31c871e9b 100644 --- a/addons/web/static/src/core/errors/error_handlers.js +++ b/addons/web/static/src/core/errors/error_handlers.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "../browser/browser"; import { ConnectionLostError, RPCError } from "../network/rpc_service"; import { registry } from "../registry"; @@ -100,7 +101,7 @@ export function lostConnectionHandler(env, error, originalError) { return true; } connectionLostNotifRemove = env.services.notification.add( - env._t("Connection lost. Trying to reconnect..."), + _t("Connection lost. Trying to reconnect..."), { sticky: true } ); let delay = 2000; @@ -112,12 +113,9 @@ export function lostConnectionHandler(env, error, originalError) { connectionLostNotifRemove(); connectionLostNotifRemove = null; } - env.services.notification.add( - env._t("Connection restored. You are back online."), - { - type: "info", - } - ); + env.services.notification.add(_t("Connection restored. You are back online."), { + type: "info", + }); }) .catch(() => { // exponential backoff, with some jitter diff --git a/addons/web/static/src/core/errors/error_service.js b/addons/web/static/src/core/errors/error_service.js index 71aca19045d..498731efb5f 100644 --- a/addons/web/static/src/core/errors/error_service.js +++ b/addons/web/static/src/core/errors/error_service.js @@ -93,7 +93,7 @@ export const errorService = { return; } uncaughtError = new UncaughtCorsError(); - uncaughtError.traceback = env._t( + uncaughtError.traceback = _t( `Unknown CORS error\n\n` + `An unknown CORS error occured.\n` + `The error probably originates from a JavaScript file served from a different origin.\n` + diff --git a/addons/web/static/src/core/file_upload/file_upload_progress_bar.js b/addons/web/static/src/core/file_upload/file_upload_progress_bar.js index 59a3d4ec0f0..d4165aef31c 100644 --- a/addons/web/static/src/core/file_upload/file_upload_progress_bar.js +++ b/addons/web/static/src/core/file_upload/file_upload_progress_bar.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "../utils/hooks"; import { ConfirmationDialog } from "../confirmation_dialog/confirmation_dialog"; @@ -15,10 +16,7 @@ export class FileUploadProgressBar extends Component { return; } this.dialogService.add(ConfirmationDialog, { - body: this.env._t( - "Do you really want to cancel the upload of %s?", - this.props.fileUpload.title - ), + body: _t("Do you really want to cancel the upload of %s?", this.props.fileUpload.title), confirm: () => { this.props.fileUpload.xhr.abort(); }, diff --git a/addons/web/static/src/core/file_upload/file_upload_progress_record.js b/addons/web/static/src/core/file_upload/file_upload_progress_record.js index 47ac33e5c2d..4a0dc7f70b5 100644 --- a/addons/web/static/src/core/file_upload/file_upload_progress_record.js +++ b/addons/web/static/src/core/file_upload/file_upload_progress_record.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { FileUploadProgressBar } from "./file_upload_progress_bar"; import { Component } from "@odoo/owl"; @@ -10,15 +11,15 @@ export class FileUploadProgressRecord extends Component { const percent = Math.round(fileUpload.progress * 100); if (percent === 100) { return { - left: this.env._t("Processing..."), + left: _t("Processing..."), right: "", }; } else { const mbLoaded = Math.round(fileUpload.loaded / 1000000); const mbTotal = Math.round(fileUpload.total / 1000000); return { - left: this.env._t("Uploading... (%s%)", percent), - right: this.env._t("(%s/%sMB)", mbLoaded, mbTotal), + left: _t("Uploading... (%s%)", percent), + right: _t("(%s/%sMB)", mbLoaded, mbTotal), }; } } diff --git a/addons/web/static/src/core/file_upload/file_upload_service.js b/addons/web/static/src/core/file_upload/file_upload_service.js index 1ff5326c87d..189ccba41a7 100644 --- a/addons/web/static/src/core/file_upload/file_upload_service.js +++ b/addons/web/static/src/core/file_upload/file_upload_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "../registry"; import { EventBus, reactive } from "@odoo/owl"; @@ -55,7 +56,7 @@ export const fileUploadService = { loaded: 0, total: 0, state: "pending", - title: files.length === 1 ? files[0].name : env._t("%s Files", files.length), + title: files.length === 1 ? files[0].name : _t("%s Files", files.length), type: files.length === 1 ? files[0].type : undefined, }); uploads[upload.id] = upload; @@ -77,9 +78,12 @@ export const fileUploadService = { delete uploads[upload.id]; upload.state = "error"; // Disable this option if you need more explicit error handling. - if (params.displayErrorNotification !== undefined && params.displayErrorNotification) { - notificationService.add(env._t("An error occured while uploading."), { - title: env._t("Error"), + if ( + params.displayErrorNotification !== undefined && + params.displayErrorNotification + ) { + notificationService.add(_t("An error occured while uploading."), { + title: _t("Error"), sticky: true, }); } diff --git a/addons/web/static/src/core/l10n/localization_service.js b/addons/web/static/src/core/l10n/localization_service.js index 07dc1d9b232..2619f5a2341 100644 --- a/addons/web/static/src/core/l10n/localization_service.js +++ b/addons/web/static/src/core/l10n/localization_service.js @@ -5,7 +5,7 @@ import { browser } from "../browser/browser"; import { registry } from "../registry"; import { strftimeToLuxonFormat } from "./dates"; import { localization } from "./localization"; -import { _t, translatedTerms, translationLoaded, translationIsReady } from "./translation"; +import { translatedTerms, translationLoaded, translationIsReady } from "./translation"; const { Settings } = luxon; @@ -57,7 +57,6 @@ export const localizationService = { Object.assign(translatedTerms, terms); translatedTerms[translationLoaded] = true; translationIsReady.resolve(true); - env._t = _t; // Setup lang inside luxon. The locale codes received from the server contain "_", // whereas the Intl codes use "-" (Unicode BCP 47). There's only one exception, which @@ -87,7 +86,7 @@ export const localizationService = { multiLang, thousandsSep: userLocalization.thousands_sep, weekStart: userLocalization.week_start, - code:language, + code: language, }); return localization; }, diff --git a/addons/web/static/src/core/signature/signature_dialog.js b/addons/web/static/src/core/signature/signature_dialog.js index a30209a31b5..b125f626f80 100644 --- a/addons/web/static/src/core/signature/signature_dialog.js +++ b/addons/web/static/src/core/signature/signature_dialog.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dialog } from "@web/core/dialog/dialog"; import { NameAndSignature } from "./name_and_signature"; @@ -7,7 +8,7 @@ import { Component, useState } from "@odoo/owl"; export class SignatureDialog extends Component { setup() { - this.title = this.env._t("Adopt Your Signature"); + this.title = _t("Adopt Your Signature"); this.signature = useState({ name: this.props.defaultName, isSignatureEmpty: true, diff --git a/addons/web/static/src/core/ui/block_ui.js b/addons/web/static/src/core/ui/block_ui.js index baf9d7d0385..89eaba46e6d 100644 --- a/addons/web/static/src/core/ui/block_ui.js +++ b/addons/web/static/src/core/ui/block_ui.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { EventBus, Component, useState, xml } from "@odoo/owl"; @@ -7,33 +8,31 @@ import { EventBus, Component, useState, xml } from "@odoo/owl"; export class BlockUI extends Component { setup() { this.messagesByDuration = [ - { time: 20, l1: this.env._t("Loading...") }, - { time: 40, l1: this.env._t("Still loading...") }, + { time: 20, l1: _t("Loading...") }, + { time: 40, l1: _t("Still loading...") }, { time: 60, - l1: this.env._t("Still loading..."), - l2: this.env._t("Please be patient."), + l1: _t("Still loading..."), + l2: _t("Please be patient."), }, { time: 180, - l1: this.env._t("Don't leave yet,"), - l2: this.env._t("it's still loading..."), + l1: _t("Don't leave yet,"), + l2: _t("it's still loading..."), }, { time: 120, - l1: this.env._t("You may not believe it,"), - l2: this.env._t("but the application is actually loading..."), + l1: _t("You may not believe it,"), + l2: _t("but the application is actually loading..."), }, { time: 3180, - l1: this.env._t("Take a minute to get a coffee,"), - l2: this.env._t("because it's loading..."), + l1: _t("Take a minute to get a coffee,"), + l2: _t("because it's loading..."), }, { time: null, - l1: this.env._t( - "Maybe you should consider reloading the application by pressing F5..." - ), + l1: _t("Maybe you should consider reloading the application by pressing F5..."), }, ]; this.state = useState({ diff --git a/addons/web/static/src/env.js b/addons/web/static/src/env.js index 76091cf5f02..5db7a84002c 100644 --- a/addons/web/static/src/env.js +++ b/addons/web/static/src/env.js @@ -31,9 +31,6 @@ export function makeEnv() { bus: new EventBus(), services: {}, debug: odoo.debug, - _t: () => { - throw new Error("Translations are not ready yet. Maybe use _lt instead?"); - }, get isSmall() { throw new Error("UI service not initialized!"); }, diff --git a/addons/web/static/src/legacy/js/common_env.js b/addons/web/static/src/legacy/js/common_env.js index e2bb7bfca96..937c05f6cc5 100644 --- a/addons/web/static/src/legacy/js/common_env.js +++ b/addons/web/static/src/legacy/js/common_env.js @@ -21,7 +21,6 @@ import { bus } from "@web/legacy/js/services/core"; import rpc from "@web/legacy/js/core/rpc"; import session from "web.session"; - import { _t } from "@web/legacy/js/core/translation"; import {getCookie, setCookie} from "@web/legacy/js/core/cookie_utils"; const { device, isDebug } = config @@ -44,7 +43,6 @@ // Build the basic env const env = { - _t, browser, bus, device, diff --git a/addons/web/static/src/legacy/js/owl_compatibility.js b/addons/web/static/src/legacy/js/owl_compatibility.js index 6a255d346ad..3cb879f3144 100644 --- a/addons/web/static/src/legacy/js/owl_compatibility.js +++ b/addons/web/static/src/legacy/js/owl_compatibility.js @@ -2,6 +2,7 @@ import { LegacyComponent } from "@web/legacy/legacy_component"; import { templates } from "@web/core/assets"; + import { _t } from "@web/core/l10n/translation"; /** * This file defines the necessary tools for the transition phase where Odoo @@ -284,7 +285,7 @@ env, dev: env.isDebug(), translatableAttributes: ["data-tooltip"], - translateFn: env._t, + translateFn: _t, }); if (!("Component" in props)) { props.Component = owl.Component; @@ -540,7 +541,7 @@ templates, dev: "isDebug" in env ? env.isDebug() : env.debug, translatableAttributes: ["data-tooltip"], - translateFn: env._t, + translateFn: _t, }; const app = new App(null, appConfig); this.app = app; diff --git a/addons/web/static/src/model/relational_model/record.js b/addons/web/static/src/model/relational_model/record.js index 9d3579661aa..3315ee76d86 100644 --- a/addons/web/static/src/model/relational_model/record.js +++ b/addons/web/static/src/model/relational_model/record.js @@ -615,7 +615,7 @@ export class Record extends DataPoint { } else if (property.type === "many2one") { parsedValues[fieldPropertyName] = property.value.length && property.value[1] === null - ? [property.value[0], this.model.env._t("No Access")] + ? [property.value[0], this.model._t("No Access")] : property.value; } else { parsedValues[fieldPropertyName] = property.value ?? false; diff --git a/addons/web/static/src/search/control_panel/control_panel.js b/addons/web/static/src/search/control_panel/control_panel.js index 3c3b5200bd1..1243b290ae0 100644 --- a/addons/web/static/src/search/control_panel/control_panel.js +++ b/addons/web/static/src/search/control_panel/control_panel.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service"; import { Pager } from "@web/core/pager/pager"; @@ -33,14 +34,10 @@ export class ControlPanel extends Component { const { viewSwitcherEntries, viewType } = this.env.config; for (const view of viewSwitcherEntries || []) { - useCommand( - this.env._t("Show %s view", view.name), - () => this.onViewClicked(view.type), - { - category: "view_switcher", - isAvailable: () => view.type !== viewType, - } - ); + useCommand(_t("Show %s view", view.name), () => this.onViewClicked(view.type), { + category: "view_switcher", + isAvailable: () => view.type !== viewType, + }); } useExternalListener(window, "click", this.onWindowClick); diff --git a/addons/web/static/src/search/custom_favorite_item/custom_favorite_item.js b/addons/web/static/src/search/custom_favorite_item/custom_favorite_item.js index a5ddeb1243b..4cdefcdbea1 100644 --- a/addons/web/static/src/search/custom_favorite_item/custom_favorite_item.js +++ b/addons/web/static/src/search/custom_favorite_item/custom_favorite_item.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { AccordionItem } from "@web/core/dropdown/accordion_item"; import { CheckBox } from "@web/core/checkbox/checkbox"; import { registry } from "@web/core/registry"; @@ -25,10 +26,9 @@ export class CustomFavoriteItem extends Component { */ saveFavorite(ev) { if (!this.state.description) { - this.notificationService.add( - this.env._t("A name for your favorite filter is required."), - { type: "danger" } - ); + this.notificationService.add(_t("A name for your favorite filter is required."), { + type: "danger", + }); ev.stopPropagation(); return this.descriptionRef.el.focus(); } @@ -36,7 +36,7 @@ export class CustomFavoriteItem extends Component { (s) => s.type === "favorite" && s.description === this.state.description ); if (favorites.length) { - this.notificationService.add(this.env._t("A filter with same name already exists."), { + this.notificationService.add(_t("A filter with same name already exists."), { type: "danger", }); ev.stopPropagation(); diff --git a/addons/web/static/src/search/search_bar/search_bar.js b/addons/web/static/src/search/search_bar/search_bar.js index 708743ffa99..4f7566a63bb 100644 --- a/addons/web/static/src/search/search_bar/search_bar.js +++ b/addons/web/static/src/search/search_bar/search_bar.js @@ -133,7 +133,7 @@ export class SearchBar extends Component { const fieldType = type === "reference" ? "char" : type; /** @todo do something with respect to localization (rtl) */ - let preposition = this.env._t(["date", "datetime"].includes(fieldType) ? "at" : "for"); + let preposition = _t(["date", "datetime"].includes(fieldType) ? "at" : "for"); if ((isFieldProperty && FOLDABLE_TYPES.includes(fieldType)) || fieldType === "properties") { // Do not chose preposition for foldable properties @@ -143,8 +143,8 @@ export class SearchBar extends Component { if (["selection", "boolean", "tags"].includes(fieldType)) { const booleanOptions = [ - [true, this.env._t("Yes")], - [false, this.env._t("No")], + [true, _t("Yes")], + [false, _t("No")], ]; let options; if (isFieldProperty) { @@ -288,7 +288,7 @@ export class SearchBar extends Component { id: nextItemId++, isChild: true, searchItemId: searchItem.id, - label: this.env._t("(no result)"), + label: _t("(no result)"), unselectable: true, }); } diff --git a/addons/web/static/src/search/search_bar_menu/search_bar_menu.js b/addons/web/static/src/search/search_bar_menu/search_bar_menu.js index 020b70d87e3..75587be4637 100644 --- a/addons/web/static/src/search/search_bar_menu/search_bar_menu.js +++ b/addons/web/static/src/search/search_bar_menu/search_bar_menu.js @@ -197,12 +197,10 @@ export class SearchBarMenu extends Component { openConfirmationDialog(itemId) { const { userId } = this.favoriteItems.find((item) => item.id === itemId); const dialogProps = { - title: this.env._t("Warning"), + title: _t("Warning"), body: userId - ? this.env._t("Are you sure that you want to remove this filter?") - : this.env._t( - "This filter is global and will be removed for everybody if you continue." - ), + ? _t("Are you sure that you want to remove this filter?") + : _t("This filter is global and will be removed for everybody if you continue."), confirm: () => this.env.searchModel.deleteFavorite(itemId), cancel: () => {}, }; diff --git a/addons/web/static/src/search/search_model.js b/addons/web/static/src/search/search_model.js index 94a90e4ebf5..4491ce44e03 100644 --- a/addons/web/static/src/search/search_model.js +++ b/addons/web/static/src/search/search_model.js @@ -1655,7 +1655,7 @@ export class SearchModel extends EventBus { groupId: group.id, type, values, - separator: type === "groupBy" ? ">" : this.env._t("or"), + separator: type === "groupBy" ? ">" : _t("or"), }; if (type === "field") { facet.title = title; diff --git a/addons/web/static/src/start.js b/addons/web/static/src/start.js index 678d756571c..c6689854a62 100644 --- a/addons/web/static/src/start.js +++ b/addons/web/static/src/start.js @@ -8,7 +8,7 @@ import { session } from "@web/session"; import { renderToString } from "./core/utils/render"; import { setLoadXmlDefaultApp, templates } from "@web/core/assets"; import { hasTouch } from "@web/core/browser/feature_detection"; - +import { _t } from "@web/core/l10n/translation"; import { App, whenReady } from "@odoo/owl"; /** @@ -43,7 +43,7 @@ export async function startWebClient(Webclient) { dev: env.debug, warnIfNoStaticProps: true, translatableAttributes: ["data-tooltip"], - translateFn: env._t, + translateFn: _t, }); renderToString.app = app; setLoadXmlDefaultApp(app); diff --git a/addons/web/static/src/views/calendar/calendar_common/calendar_common_popover.js b/addons/web/static/src/views/calendar/calendar_common/calendar_common_popover.js index e08f544f9e2..6eaf44f708c 100644 --- a/addons/web/static/src/views/calendar/calendar_common/calendar_common_popover.js +++ b/addons/web/static/src/views/calendar/calendar_common/calendar_common_popover.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dialog } from "@web/core/dialog/dialog"; import { evaluateBooleanExpr } from "@web/core/py_js/py"; import { is24HourFormat } from "@web/core/l10n/dates"; @@ -48,13 +49,11 @@ export class CalendarCommonPopover extends Component { const duration = end.diff(start, ["hours", "minutes"]); const formatParts = []; if (duration.hours > 0) { - const hourString = - duration.hours === 1 ? this.env._t("hour") : this.env._t("hours"); + const hourString = duration.hours === 1 ? _t("hour") : _t("hours"); formatParts.push(`h '${hourString}'`); } if (duration.minutes > 0) { - const minuteStr = - duration.minutes === 1 ? this.env._t("minute") : this.env._t("minutes"); + const minuteStr = duration.minutes === 1 ? _t("minute") : _t("minutes"); formatParts.push(`m '${minuteStr}'`); } this.timeDuration = duration.toFormat(formatParts.join(", ")); @@ -65,10 +64,10 @@ export class CalendarCommonPopover extends Component { if (record.isAllDay) { if (isSameDay) { - this.dateDuration = this.env._t("All day"); + this.dateDuration = _t("All day"); } else { const duration = end.plus({ day: 1 }).diff(start, "days"); - this.dateDuration = duration.toFormat(`d '${this.env._t("days")}'`); + this.dateDuration = duration.toFormat(`d '${_t("days")}'`); } } } diff --git a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js index b8c178c593a..c5db107c107 100644 --- a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js +++ b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { is24HourFormat } from "@web/core/l10n/dates"; import { localization } from "@web/core/l10n/localization"; import { renderToString } from "@web/core/utils/render"; @@ -54,7 +55,7 @@ export class CalendarCommonRenderer extends Component { get options() { return { allDaySlot: this.props.model.hasAllDaySlot, - allDayText: this.env._t("All day"), + allDayText: _t("All day"), columnHeaderFormat: this.env.isSmall ? SHORT_SCALE_TO_HEADER_FORMAT[this.props.model.scale] : SCALE_TO_HEADER_FORMAT[this.props.model.scale], @@ -94,8 +95,7 @@ export class CalendarCommonRenderer extends Component { snapDuration: { minutes: 15 }, timeZone: luxon.Settings.defaultZone.name, unselectAuto: false, - weekLabel: - this.props.model.scale === "month" && this.env.isSmall ? "" : this.env._t("Week"), + weekLabel: this.props.model.scale === "month" && this.env.isSmall ? "" : _t("Week"), weekends: this.props.isWeekendVisible, weekNumberCalculation: "ISO", weekNumbers: true, diff --git a/addons/web/static/src/views/calendar/calendar_controller.js b/addons/web/static/src/views/calendar/calendar_controller.js index 7fdc2c54056..848e16fad09 100644 --- a/addons/web/static/src/views/calendar/calendar_controller.js +++ b/addons/web/static/src/views/calendar/calendar_controller.js @@ -211,8 +211,8 @@ export class CalendarController extends Component { } deleteRecord(record) { this.displayDialog(ConfirmationDialog, { - title: this.env._t("Confirmation"), - body: this.env._t("Are you sure you want to delete this record?"), + title: _t("Confirmation"), + body: _t("Are you sure you want to delete this record?"), confirm: () => { this.model.unlinkRecord(record.id); }, diff --git a/addons/web/static/src/views/calendar/calendar_model.js b/addons/web/static/src/views/calendar/calendar_model.js index 016e6f68fa9..e73b3d9fd7f 100644 --- a/addons/web/static/src/views/calendar/calendar_model.js +++ b/addons/web/static/src/views/calendar/calendar_model.js @@ -828,9 +828,7 @@ export class CalendarModel extends Model { type: "all", recordId: null, value: "all", - label: isUserOrPartner - ? this.env._t("Everybody's calendars") - : this.env._t("Everything"), + label: isUserOrPartner ? _t("Everybody's calendars") : _t("Everything"), active: previousAllFilter ? previousAllFilter.active : false, canRemove: false, colorIndex: null, diff --git a/addons/web/static/src/views/calendar/quick_create/calendar_quick_create.js b/addons/web/static/src/views/calendar/quick_create/calendar_quick_create.js index cbd142f6bab..28e8bd67069 100644 --- a/addons/web/static/src/views/calendar/quick_create/calendar_quick_create.js +++ b/addons/web/static/src/views/calendar/quick_create/calendar_quick_create.js @@ -46,8 +46,8 @@ export class CalendarQuickCreate extends Component { } } else { this.titleRef.el.classList.add("o_field_invalid"); - this.notification.add(this.env._t("Meeting Subject"), { - title: this.env._t("Invalid fields"), + this.notification.add(_t("Meeting Subject"), { + title: _t("Invalid fields"), type: "danger", }); } diff --git a/addons/web/static/src/views/debug_items.js b/addons/web/static/src/views/debug_items.js index 23c4510aec8..3e9c07635fc 100644 --- a/addons/web/static/src/views/debug_items.js +++ b/addons/web/static/src/views/debug_items.js @@ -44,7 +44,7 @@ export function getView({ component, env }) { } return { type: "item", - description: env._t("Get View"), + description: _t("Get View"), callback: () => { env.services.dialog.add(GetViewDialog, { arch }); }, @@ -73,7 +73,7 @@ export function editView({ accessRights, component, env }) { return; } const displayName = type[0].toUpperCase() + type.slice(1); - const description = env._t("Edit View: ") + displayName; + const description = _t("Edit View: ") + displayName; return { type: "item", description, @@ -105,7 +105,7 @@ export function editSearchView({ accessRights, component, env }) { if (searchViewId === undefined) { return null; } - const description = env._t("Edit SearchView"); + const description = _t("Edit SearchView"); return { type: "item", description, @@ -126,7 +126,7 @@ class GetMetadataDialog extends Component { setup() { this.orm = useService("orm"); this.dialogService = useService("dialog"); - this.title = this.env._t("View Metadata"); + this.title = _t("View Metadata"); this.state = useState({}); onWillStart(() => this.loadMetadata()); } @@ -176,7 +176,7 @@ export function viewMetadata({ component, env }) { } return { type: "item", - description: env._t("View Metadata"), + description: _t("View Metadata"), callback: () => { env.services.dialog.add(GetMetadataDialog, { resModel: component.props.resModel, @@ -196,7 +196,7 @@ debugRegistry.category("form").add("viewMetadata", viewMetadata); class SetDefaultDialog extends Component { setup() { this.orm = useService("orm"); - this.title = this.env._t("Set Defaults"); + this.title = _t("Set Defaults"); this.state = { fieldToSet: "", condition: "", @@ -308,7 +308,7 @@ SetDefaultDialog.props = { export function setDefaults({ component, env }) { return { type: "item", - description: env._t("Set Defaults"), + description: _t("Set Defaults"), callback: () => { env.services.dialog.add(SetDefaultDialog, { record: component.model.root, @@ -329,7 +329,7 @@ export function manageAttachments({ component, env }) { if (!resId) { return null; // No record } - const description = env._t("Manage Attachments"); + const description = _t("Manage Attachments"); return { type: "item", description, diff --git a/addons/web/static/src/views/fields/copy_clipboard/copy_clipboard_field.js b/addons/web/static/src/views/fields/copy_clipboard/copy_clipboard_field.js index d3edd759bdb..aeb22522ab1 100644 --- a/addons/web/static/src/views/fields/copy_clipboard/copy_clipboard_field.js +++ b/addons/web/static/src/views/fields/copy_clipboard/copy_clipboard_field.js @@ -22,8 +22,8 @@ class CopyClipboardField extends Component { }; setup() { - this.copyText = this.props.string || this.env._t("Copy"); - this.successText = this.env._t("Copied"); + this.copyText = this.props.string || _t("Copy"); + this.successText = _t("Copied"); } get copyButtonClassName() { diff --git a/addons/web/static/src/views/fields/domain/domain_field.js b/addons/web/static/src/views/fields/domain/domain_field.js index 43427068bbd..6f7471691d2 100644 --- a/addons/web/static/src/views/fields/domain/domain_field.js +++ b/addons/web/static/src/views/fields/domain/domain_field.js @@ -184,7 +184,7 @@ export class DomainField extends Component { this.addDialog( SelectCreateDialog, { - title: this.env._t("Selected records"), + title: _t("Selected records"), noCreate: true, multiSelect: false, resModel: this.getResModel(), diff --git a/addons/web/static/src/views/fields/dynamic_placeholder_hook.js b/addons/web/static/src/views/fields/dynamic_placeholder_hook.js index 8ac59bddfa2..b893a3a0a4e 100644 --- a/addons/web/static/src/views/fields/dynamic_placeholder_hook.js +++ b/addons/web/static/src/views/fields/dynamic_placeholder_hook.js @@ -3,6 +3,7 @@ import { usePopover } from "@web/core/popover/popover_hook"; import { useService } from "@web/core/utils/hooks"; import { useComponent } from "@odoo/owl"; +import { _t } from "@web/core/l10n/translation"; import { DynamicPlaceholderPopover } from "./dynamic_placeholder_popover"; export function useDynamicPlaceholder(elementRef) { @@ -64,9 +65,7 @@ export function useDynamicPlaceholder(elementRef) { async function open(opts) { if (!model) { return notification.add( - ownerField.env._t( - "You need to select a model before opening the dynamic placeholder selector." - ), + _t("You need to select a model before opening the dynamic placeholder selector."), { type: "danger" } ); } diff --git a/addons/web/static/src/views/fields/file_handler.js b/addons/web/static/src/views/fields/file_handler.js index 5fcae8fc728..5f5ba84bb75 100644 --- a/addons/web/static/src/views/fields/file_handler.js +++ b/addons/web/static/src/views/fields/file_handler.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; import { getDataURLFromFile } from "@web/core/utils/urls"; import { checkFileSize } from "@web/core/utils/files"; @@ -30,12 +31,9 @@ export class FileUploader extends Component { const data = await getDataURLFromFile(file); if (!file.size) { console.warn(`Error while uploading file : ${file.name}`); - this.notification.add( - this.env._t("There was a problem while uploading your file."), - { - type: "danger", - } - ); + this.notification.add(_t("There was a problem while uploading your file."), { + type: "danger", + }); } try { await this.props.onUploaded({ diff --git a/addons/web/static/src/views/fields/image/image_field.js b/addons/web/static/src/views/fields/image/image_field.js index 02cb02bc419..8e290212499 100644 --- a/addons/web/static/src/views/fields/image/image_field.js +++ b/addons/web/static/src/views/fields/image/image_field.js @@ -57,7 +57,7 @@ export class ImageField extends Component { setup() { this.notification = useService("notification"); - this.orm = useService('orm'); + this.orm = useService("orm"); this.isMobile = isMobileOS(); this.state = useState({ isValid: true, @@ -127,55 +127,68 @@ export class ImageField extends Component { } async onFileUploaded(info) { this.state.isValid = true; - if (info.type === 'image/webp') { + if (info.type === "image/webp") { // Generate alternate sizes and format for reports. - const image = document.createElement('img'); + const image = document.createElement("img"); image.src = `data:image/webp;base64,${info.data}`; - await new Promise(resolve => image.addEventListener('load', resolve)); + await new Promise((resolve) => image.addEventListener("load", resolve)); const originalSize = Math.max(image.width, image.height); - const smallerSizes = [1024, 512, 256, 128].filter(size => size < originalSize); + const smallerSizes = [1024, 512, 256, 128].filter((size) => size < originalSize); let referenceId = undefined; for (const size of [originalSize, ...smallerSizes]) { const ratio = size / originalSize; - const canvas = document.createElement('canvas'); + const canvas = document.createElement("canvas"); canvas.width = image.width * ratio; canvas.height = image.height * ratio; - const ctx = canvas.getContext('2d'); - ctx.fillStyle = 'rgb(255, 255, 255)'; + const ctx = canvas.getContext("2d"); + ctx.fillStyle = "rgb(255, 255, 255)"; ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height); - const [resizedId] = await this.orm.call( - 'ir.attachment', - 'create_unique', - [[{ - 'name': info.name, - 'description': size === originalSize ? '' : `resize: ${size}`, - 'datas': size === originalSize ? info.data : canvas.toDataURL('image/webp', 0.75).split(',')[1], - 'res_id': referenceId, - 'res_model': 'ir.attachment', - 'mimetype': 'image/webp', - }]], + ctx.drawImage( + image, + 0, + 0, + image.width, + image.height, + 0, + 0, + canvas.width, + canvas.height ); + const [resizedId] = await this.orm.call("ir.attachment", "create_unique", [ + [ + { + name: info.name, + description: size === originalSize ? "" : `resize: ${size}`, + datas: + size === originalSize + ? info.data + : canvas.toDataURL("image/webp", 0.75).split(",")[1], + res_id: referenceId, + res_model: "ir.attachment", + mimetype: "image/webp", + }, + ], + ]); referenceId = referenceId || resizedId; // Keep track of original. - await this.orm.call( - 'ir.attachment', - 'create_unique', - [[{ - 'name': info.name.replace(/\.webp$/, '.jpg'), - 'description': 'format: jpeg', - 'datas': canvas.toDataURL('image/jpeg', 0.75).split(',')[1], - 'res_id': resizedId, - 'res_model': 'ir.attachment', - 'mimetype': 'image/jpeg', - }]], - ); + await this.orm.call("ir.attachment", "create_unique", [ + [ + { + name: info.name.replace(/\.webp$/, ".jpg"), + description: "format: jpeg", + datas: canvas.toDataURL("image/jpeg", 0.75).split(",")[1], + res_id: resizedId, + res_model: "ir.attachment", + mimetype: "image/jpeg", + }, + ], + ]); } } this.props.record.update({ [this.props.name]: info.data }); } onLoadFailed() { this.state.isValid = false; - this.notification.add(this.env._t("Could not display the selected image"), { + this.notification.add(_t("Could not display the selected image"), { type: "danger", }); } diff --git a/addons/web/static/src/views/fields/image_url/image_url_field.js b/addons/web/static/src/views/fields/image_url/image_url_field.js index e14e7de4ea7..e6b7f4a0be1 100644 --- a/addons/web/static/src/views/fields/image_url/image_url_field.js +++ b/addons/web/static/src/views/fields/image_url/image_url_field.js @@ -43,7 +43,7 @@ export class ImageUrlField extends Component { onLoadFailed() { this.state.src = this.constructor.fallbackSrc; - this.notification.add(this.env._t("Could not display the specified image url."), { + this.notification.add(_t("Could not display the specified image url."), { type: "info", }); } diff --git a/addons/web/static/src/views/fields/many2many_binary/many2many_binary_field.js b/addons/web/static/src/views/fields/many2many_binary/many2many_binary_field.js index a13a503673c..bb6b8910507 100644 --- a/addons/web/static/src/views/fields/many2many_binary/many2many_binary_field.js +++ b/addons/web/static/src/views/fields/many2many_binary/many2many_binary_field.js @@ -50,7 +50,7 @@ export class Many2ManyBinaryField extends Component { for (const file of files) { if (file.error) { return this.notification.add(file.error, { - title: this.env._t("Uploading error"), + title: _t("Uploading error"), type: "danger", }); } diff --git a/addons/web/static/src/views/fields/many2many_tags_avatar/many2many_tags_avatar_field.js b/addons/web/static/src/views/fields/many2many_tags_avatar/many2many_tags_avatar_field.js index 91a500c0689..4a4627bf2ae 100644 --- a/addons/web/static/src/views/fields/many2many_tags_avatar/many2many_tags_avatar_field.js +++ b/addons/web/static/src/views/fields/many2many_tags_avatar/many2many_tags_avatar_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { usePopover } from "@web/core/popover/popover_hook"; import { registry } from "@web/core/registry"; import { @@ -119,7 +120,7 @@ export class KanbanMany2ManyTagsAvatarFieldTagsList extends TagsList { canCreate: false, canCreateEdit: false, canQuickCreate: false, - placeholder: this.env._t("Search users..."), + placeholder: _t("Search users..."), }); } get canDisplayQuickAssignAvatar() { diff --git a/addons/web/static/src/views/fields/many2one/many2one_field.js b/addons/web/static/src/views/fields/many2one/many2one_field.js index 0944f1b9976..38a670e4325 100644 --- a/addons/web/static/src/views/fields/many2one/many2one_field.js +++ b/addons/web/static/src/views/fields/many2one/many2one_field.js @@ -19,7 +19,7 @@ class CreateConfirmationDialog extends Component { static components = { Dialog }; get title() { - return this.env._t("New: %s", this.props.name); + return _t("New: %s", this.props.name); } async onCreate() { @@ -271,7 +271,7 @@ export class Many2OneField extends Component { browser.navigator.vibrate(100); } } else { - this.notification.add(this.env._t("Please, scan again!"), { + this.notification.add(_t("Please, scan again!"), { type: "warning", }); } diff --git a/addons/web/static/src/views/fields/many2one_avatar/many2one_avatar_field.js b/addons/web/static/src/views/fields/many2one_avatar/many2one_avatar_field.js index 62bf6a60ebb..4d9f247d268 100644 --- a/addons/web/static/src/views/fields/many2one_avatar/many2one_avatar_field.js +++ b/addons/web/static/src/views/fields/many2one_avatar/many2one_avatar_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { usePopover } from "@web/core/popover/popover_hook"; import { many2OneField, Many2OneField } from "../many2one/many2one_field"; @@ -85,7 +86,7 @@ export class KanbanMany2OneAvatarField extends Many2OneAvatarField { canCreate: false, canCreateEdit: false, canQuickCreate: false, - placeholder: this.env._t("Search user..."), + placeholder: _t("Search user..."), }); } } diff --git a/addons/web/static/src/views/fields/pdf_viewer/pdf_viewer_field.js b/addons/web/static/src/views/fields/pdf_viewer/pdf_viewer_field.js index e98a5b1d77d..883f591c09f 100644 --- a/addons/web/static/src/views/fields/pdf_viewer/pdf_viewer_field.js +++ b/addons/web/static/src/views/fields/pdf_viewer/pdf_viewer_field.js @@ -79,7 +79,7 @@ export class PdfViewerField extends Component { onLoadFailed() { this.state.isValid = false; - this.notification.add(this.env._t("Could not display the selected pdf"), { + this.notification.add(_t("Could not display the selected pdf"), { type: "danger", }); } diff --git a/addons/web/static/src/views/fields/priority/priority_field.js b/addons/web/static/src/views/fields/priority/priority_field.js index 200d3358797..a33ef944035 100644 --- a/addons/web/static/src/views/fields/priority/priority_field.js +++ b/addons/web/static/src/views/fields/priority/priority_field.js @@ -27,7 +27,7 @@ export class PriorityField extends Component { } get commands() { - const commandName = this.env._t("Set priority..."); + const commandName = _t("Set priority..."); return [ [ commandName, diff --git a/addons/web/static/src/views/fields/properties/properties_field.js b/addons/web/static/src/views/fields/properties/properties_field.js index 2c263f4376f..f3ef466786b 100644 --- a/addons/web/static/src/views/fields/properties/properties_field.js +++ b/addons/web/static/src/views/fields/properties/properties_field.js @@ -581,7 +581,7 @@ async function actionAddProperty(env) { if (addProperty) { addProperty.click(); } else { - const message = env._t("You can not create a new property."); + const message = _t("You can not create a new property."); env.services.notification.add(message, { type: "danger" }); } } diff --git a/addons/web/static/src/views/fields/properties/property_definition.js b/addons/web/static/src/views/fields/properties/property_definition.js index ad5c8f1e2a3..9de7d75c333 100644 --- a/addons/web/static/src/views/fields/properties/property_definition.js +++ b/addons/web/static/src/views/fields/properties/property_definition.js @@ -245,7 +245,7 @@ export class PropertyDefinition extends Component { */ onButtonDomainClick() { this.addDialog(SelectCreateDialog, { - title: this.env._t("Selected records"), + title: _t("Selected records"), noCreate: true, multiSelect: false, resModel: this.state.propertyDefinition.comodel, diff --git a/addons/web/static/src/views/fields/relational_utils.js b/addons/web/static/src/views/fields/relational_utils.js index 8585cff8e69..65be6f302e2 100644 --- a/addons/web/static/src/views/fields/relational_utils.js +++ b/addons/web/static/src/views/fields/relational_utils.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { AutoComplete } from "@web/core/autocomplete/autocomplete"; import { makeContext } from "@web/core/context"; import { Dialog } from "@web/core/dialog/dialog"; @@ -50,12 +51,11 @@ import { // Commons // export function useSelectCreate({ resModel, activeActions, onSelected, onCreateEdit, onUnselect }) { - const env = useEnv(); const addDialog = useOwnedDialogs(); function selectCreate({ domain, context, filters, title }) { addDialog(SelectCreateDialog, { - title: title || env._t("Select records"), + title: title || _t("Select records"), noCreate: !activeActions.create, multiSelect: "link" in activeActions ? activeActions.link : false, // LPE Fixme resModel, @@ -223,7 +223,7 @@ export class Many2XAutocomplete extends Component { } get optionsSource() { return { - placeholder: this.env._t("Loading..."), + placeholder: _t("Loading..."), options: this.loadOptionsSource.bind(this), }; } @@ -282,7 +282,7 @@ export class Many2XAutocomplete extends Component { if (this.props.quickCreate && request.length) { options.push({ - label: this.env._t('Create "%s"', request), + label: _t('Create "%s"', request), classList: "o_m2o_dropdown_option o_m2o_dropdown_option_create", action: async (params) => { try { @@ -303,7 +303,7 @@ export class Many2XAutocomplete extends Component { if (!this.props.noViewAll && records.length > 0) { options.push({ - label: this.env._t("View all"), + label: _t("View all"), action: this.onViewAll.bind(this, request), classList: "o_m2o_dropdown_option o_m2o_dropdown_option_view_all", }); @@ -315,7 +315,7 @@ export class Many2XAutocomplete extends Component { : this.activeActions.create; if (!request.length && !this.props.value && (this.props.quickCreate || canCreateEdit)) { options.push({ - label: this.env._t("Start typing..."), + label: _t("Start typing..."), classList: "o_m2o_start_typing", unselectable: true, }); @@ -324,7 +324,7 @@ export class Many2XAutocomplete extends Component { if (request.length && canCreateEdit) { const context = this.getCreationContext(request); options.push({ - label: this.env._t("Create and edit..."), + label: _t("Create and edit..."), classList: "o_m2o_dropdown_option o_m2o_dropdown_option_create_edit", action: () => this.openMany2X({ context }), }); @@ -332,7 +332,7 @@ export class Many2XAutocomplete extends Component { if (!records.length && !this.activeActions.create) { options.push({ - label: this.env._t("No records"), + label: _t("No records"), classList: "o_m2o_no_result", unselectable: true, }); @@ -362,13 +362,13 @@ export class Many2XAutocomplete extends Component { dynamicFilters = [ { - description: this.env._t("Quick search: %s", request), + description: _t("Quick search: %s", request), domain: [["id", "in", nameGets.map((nameGet) => nameGet[0])]], }, ]; } - const title = this.env._t("Search: %s", fieldString); + const title = _t("Search: %s", fieldString); this.selectCreate({ domain, context, @@ -442,7 +442,6 @@ export function useOpenMany2XRecord({ isToMany, onClose = (isNew) => {}, }) { - const env = useEnv(); const addDialog = useOwnedDialogs(); const orm = useService("orm"); @@ -460,7 +459,7 @@ export function useOpenMany2XRecord({ let resolve = () => {}; if (!title) { - title = resId ? env._t("Open: %s", fieldString) : env._t("Create %s", fieldString); + title = resId ? _t("Open: %s", fieldString) : _t("Create %s", fieldString); } const { create: canCreate, write: canWrite } = activeActions; @@ -619,7 +618,7 @@ export class X2ManyFieldDialog extends Component { const saved = await this.save({ saveAndNew: true }); if (saved) { if (this.title) { - this.title = this.title.replace(this.env._t("Open:"), this.env._t("New:")); + this.title = this.title.replace(_t("Open:"), _t("New:")); } this.render(true); } @@ -708,8 +707,8 @@ export function useOpenX2ManyRecord({ async function openRecord({ record, mode, context, title, onClose }) { if (!title) { title = record - ? env._t("Open: %s", activeField.string) - : env._t("Create %s", activeField.string); + ? _t("Open: %s", activeField.string) + : _t("Create %s", activeField.string); } const list = getList(); const { archInfo, fields: _fields } = await getFormViewInfo({ @@ -730,8 +729,7 @@ export function useOpenX2ManyRecord({ if (record) { const { delete: canDelete, onDelete } = activeActions; deleteRecord = viewMode === "kanban" && canDelete ? () => onDelete(record) : null; - deleteButtonLabel = - activeActions.type === "one2many" ? env._t("Delete") : env._t("Remove"); + deleteButtonLabel = activeActions.type === "one2many" ? _t("Delete") : _t("Remove"); } else { params.context = makeContext([list.context, context]); params.withoutParent = isMany2Many; diff --git a/addons/web/static/src/views/fields/signature/signature_field.js b/addons/web/static/src/views/fields/signature/signature_field.js index a264bd36f3d..227e5daffe5 100644 --- a/addons/web/static/src/views/fields/signature/signature_field.js +++ b/addons/web/static/src/views/fields/signature/signature_field.js @@ -124,7 +124,7 @@ export class SignatureField extends Component { onLoadFailed() { this.state.isValid = false; - this.notification.add(this.env._t("Could not display the selected image"), { + this.notification.add(_t("Could not display the selected image"), { type: "danger", }); } diff --git a/addons/web/static/src/views/fields/state_selection/state_selection_field.js b/addons/web/static/src/views/fields/state_selection/state_selection_field.js index b6b0a6d3d6c..c26a546f621 100644 --- a/addons/web/static/src/views/fields/state_selection/state_selection_field.js +++ b/addons/web/static/src/views/fields/state_selection/state_selection_field.js @@ -35,7 +35,7 @@ export class StateSelectionField extends Component { const hotkeys = ["D", "F", "G"]; for (const [index, [value, label]] of this.options.entries()) { useCommand( - this.env._t("Set kanban state as %s", label), + _t("Set kanban state as %s", label), () => { this.updateRecord(value); }, diff --git a/addons/web/static/src/views/fields/statusbar/statusbar_field.js b/addons/web/static/src/views/fields/statusbar/statusbar_field.js index 7c83446b7b7..af26981d309 100644 --- a/addons/web/static/src/views/fields/statusbar/statusbar_field.js +++ b/addons/web/static/src/views/fields/statusbar/statusbar_field.js @@ -35,7 +35,7 @@ export class StatusBarField extends Component { setup() { if (this.props.withCommand) { - const commandName = this.env._t("Move to %s...", escape(this.displayName)); + const commandName = _t("Move to %s...", escape(this.displayName)); useCommand( commandName, () => { @@ -61,7 +61,7 @@ export class StatusBarField extends Component { } ); useCommand( - this.env._t("Move to next %s", this.displayName), + _t("Move to next %s", this.displayName), () => { const options = this.computeItems(false); const nextOption = diff --git a/addons/web/static/src/views/fields/timezone_mismatch/timezone_mismatch_field.js b/addons/web/static/src/views/fields/timezone_mismatch/timezone_mismatch_field.js index b2b3e01df6e..4f898c920ae 100644 --- a/addons/web/static/src/views/fields/timezone_mismatch/timezone_mismatch_field.js +++ b/addons/web/static/src/views/fields/timezone_mismatch/timezone_mismatch_field.js @@ -41,7 +41,7 @@ export class TimezoneMismatchField extends SelectionField { } get mismatchTitle() { if (!this.props.record.data[this.props.name]) { - return this.env._t("Set a timezone on your user"); + return _t("Set a timezone on your user"); } return this.props.mismatchTitle; } diff --git a/addons/web/static/src/views/fields/translation_dialog.js b/addons/web/static/src/views/fields/translation_dialog.js index 12871219519..cb899015d24 100644 --- a/addons/web/static/src/views/fields/translation_dialog.js +++ b/addons/web/static/src/views/fields/translation_dialog.js @@ -2,14 +2,14 @@ import { Dialog } from "@web/core/dialog/dialog"; import { useService } from "@web/core/utils/hooks"; -import { loadLanguages } from "@web/core/l10n/translation"; +import { loadLanguages, _t } from "@web/core/l10n/translation"; import { Component, onWillStart } from "@odoo/owl"; export class TranslationDialog extends Component { setup() { super.setup(); - this.title = this.env._t("Translate: %s", this.props.fieldName); + this.title = _t("Translate: %s", this.props.fieldName); this.orm = useService("orm"); this.user = useService("user"); diff --git a/addons/web/static/src/views/fields/x2many/x2many_field.js b/addons/web/static/src/views/fields/x2many/x2many_field.js index bb6e702b496..c38a75d28f6 100644 --- a/addons/web/static/src/views/fields/x2many/x2many_field.js +++ b/addons/web/static/src/views/fields/x2many/x2many_field.js @@ -57,7 +57,7 @@ export class X2ManyField extends Component { : [ { type: "create", - string: this.props.addLabel || this.env._t("Add"), + string: this.props.addLabel || _t("Add"), class: "o-kanban-button-new", }, ]; @@ -230,7 +230,7 @@ export class X2ManyField extends Component { context = makeContext([this.props.context, context]); if (this.isMany2Many) { const { string } = this.props; - const title = this.env._t("Add: %s", string); + const title = _t("Add: %s", string); return this.selectCreate({ domain, context, title }); } if (editable) { diff --git a/addons/web/static/src/views/form/form_controller.js b/addons/web/static/src/views/form/form_controller.js index f6d3dad8f9f..4c9c979b31b 100644 --- a/addons/web/static/src/views/form/form_controller.js +++ b/addons/web/static/src/views/form/form_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { hasTouch } from "@web/core/browser/feature_detection"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { makeContext } from "@web/core/context"; @@ -312,7 +313,7 @@ export class FormController extends Component { } displayName() { - return this.model.root.data.display_name || this.env._t("New"); + return this.model.root.data.display_name || _t("New"); } async onPagerUpdate({ offset, resIds }) { @@ -358,7 +359,7 @@ export class FormController extends Component { archive: { isAvailable: () => this.archiveEnabled && this.model.root.isActive, sequence: 10, - description: this.env._t("Archive"), + description: _t("Archive"), icon: "oi oi-archive", callback: () => { this.dialogService.add(ConfirmationDialog, this.archiveDialogProps); @@ -368,21 +369,21 @@ export class FormController extends Component { isAvailable: () => this.archiveEnabled && !this.model.root.isActive, sequence: 20, icon: "oi oi-unarchive", - description: this.env._t("Unarchive"), + description: _t("Unarchive"), callback: () => this.model.root.unarchive(), }, duplicate: { isAvailable: () => activeActions.create && activeActions.duplicate, sequence: 30, icon: "fa fa-clone", - description: this.env._t("Duplicate"), + description: _t("Duplicate"), callback: () => this.duplicateRecord(), }, delete: { isAvailable: () => activeActions.delete && !this.model.root.isNew, sequence: 40, icon: "fa fa-trash-o", - description: this.env._t("Delete"), + description: _t("Delete"), callback: () => this.deleteRecord(), skipSave: true, }, @@ -391,8 +392,8 @@ export class FormController extends Component { get archiveDialogProps() { return { - body: this.env._t("Are you sure that you want to archive this record?"), - confirmLabel: this.env._t("Archive"), + body: _t("Are you sure that you want to archive this record?"), + confirmLabel: _t("Archive"), confirm: () => this.model.root.archive(), cancel: () => {}, }; @@ -446,14 +447,14 @@ export class FormController extends Component { get deleteConfirmationDialogProps() { return { - body: this.env._t("Are you sure you want to delete this record?"), + body: _t("Are you sure you want to delete this record?"), confirm: async () => { await this.model.root.delete(); if (!this.model.root.resId) { this.env.config.historyBack(); } }, - confirmLabel: this.env._t("Delete"), + confirmLabel: _t("Delete"), cancel: () => {}, }; } diff --git a/addons/web/static/src/views/form/form_label.js b/addons/web/static/src/views/form/form_label.js index f8e8d6b92ba..408b9241219 100644 --- a/addons/web/static/src/views/form/form_label.js +++ b/addons/web/static/src/views/form/form_label.js @@ -3,7 +3,7 @@ import { fieldVisualFeedback } from "@web/views/fields/field"; import { session } from "@web/session"; import { getTooltipInfo } from "@web/views/fields/field_tooltip"; - +import { _t } from "@web/core/l10n/translation"; import { Component } from "@odoo/owl"; export class FormLabel extends Component { @@ -35,7 +35,7 @@ export class FormLabel extends Component { const field = this.props.record.fields[this.props.fieldName]; let help = field.help || ""; if (field.company_dependent && session.display_switch_company_menu) { - help += (help ? "\n\n" : "") + this.env._t("Values set here are company-specific."); + help += (help ? "\n\n" : "") + _t("Values set here are company-specific."); } return help; } diff --git a/addons/web/static/src/views/graph/graph_model.js b/addons/web/static/src/views/graph/graph_model.js index 037b9126fd4..9bded1cafc4 100644 --- a/addons/web/static/src/views/graph/graph_model.js +++ b/addons/web/static/src/views/graph/graph_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { sortBy, groupBy } from "@web/core/utils/arrays"; import { KeepLast, Race } from "@web/core/utils/concurrency"; import { rankInterval } from "@web/search/utils/dates"; @@ -221,7 +222,7 @@ export class GraphModel extends Model { const labelMap = {}; for (const dataPt of dataPoints) { const x = dataPt.labels.slice(0, mode === "pie" ? undefined : 1); - const trueLabel = x.length ? x.join(SEP) : this.env._t("Total"); + const trueLabel = x.length ? x.join(SEP) : _t("Total"); if (dateClasses) { x[0] = dateClasses.classLabel(dataPt.originIndex, x[0]); } @@ -235,7 +236,7 @@ export class GraphModel extends Model { x[0] = dateClasses.representative(x[0]); } } - const label = x.length ? x.join(SEP) : this.env._t("Total"); + const label = x.length ? x.join(SEP) : _t("Total"); labels.push(label); } dataPt.labelIndex = labelMap[key]; @@ -303,9 +304,9 @@ export class GraphModel extends Model { _getLabel(description) { if (!description) { - return this.env._t("Sum"); + return _t("Sum"); } else { - return this.env._t("Sum (%s)", description); + return _t("Sum (%s)", description); } } @@ -378,7 +379,7 @@ export class GraphModel extends Model { * @returns {string} */ _getDefaultFilterLabel(field) { - return this.env._t("Undefined"); + return _t("Undefined"); } /** diff --git a/addons/web/static/src/views/graph/graph_renderer.js b/addons/web/static/src/views/graph/graph_renderer.js index 1824ad492f8..ea9fa6afd2a 100644 --- a/addons/web/static/src/views/graph/graph_renderer.js +++ b/addons/web/static/src/views/graph/graph_renderer.js @@ -96,7 +96,7 @@ export class GraphRenderer extends Component { const td = document.createElement("td"); tr.classList.add("o_show_more", "text-center", "fw-bold"); td.setAttribute("colspan", "2"); - td.innerText = this.env._t("..."); + td.innerText = _t("..."); tr.appendChild(td); tooltip.querySelector("tbody").appendChild(tr); } diff --git a/addons/web/static/src/views/kanban/kanban_column_quick_create.js b/addons/web/static/src/views/kanban/kanban_column_quick_create.js index 67ef76e36c6..785b0116b6e 100644 --- a/addons/web/static/src/views/kanban/kanban_column_quick_create.js +++ b/addons/web/static/src/views/kanban/kanban_column_quick_create.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useHotkey } from "@web/core/hotkeys/hotkey_hook"; import { useAutofocus, useService } from "@web/core/utils/hooks"; import { KanbanColumnExamplesDialog } from "./kanban_column_examples_dialog"; @@ -74,7 +75,7 @@ export class KanbanColumnQuickCreate extends Component { this.dialog.add(KanbanColumnExamplesDialog, { examples: this.props.exampleData.examples, applyExamplesText: - this.props.exampleData.applyExamplesText || this.env._t("Use This For My Kanban"), + this.props.exampleData.applyExamplesText || _t("Use This For My Kanban"), applyExamples: (index) => { const { examples, foldField } = this.props.exampleData; const { columns, foldedColumns = [] } = examples[index]; diff --git a/addons/web/static/src/views/kanban/kanban_header.js b/addons/web/static/src/views/kanban/kanban_header.js index 2b64c646d87..9f98bd8b400 100644 --- a/addons/web/static/src/views/kanban/kanban_header.js +++ b/addons/web/static/src/views/kanban/kanban_header.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Component, useRef } from "@odoo/owl"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { Dropdown } from "@web/core/dropdown/dropdown"; @@ -76,14 +77,14 @@ export class KanbanHeader extends Component { } _getEmptyGroupLabel(fieldName) { - return this.env._t("None"); + return _t("None"); } get groupName() { const { groupByField, displayName } = this.group; let name = displayName; if (groupByField.type === "boolean") { - name = name ? this.env._t("Yes") : this.env._t("No"); + name = name ? _t("Yes") : _t("No"); } else if (!name) { if ( isRelational(groupByField) || @@ -133,9 +134,7 @@ export class KanbanHeader extends Component { archiveGroup() { this.dialog.add(ConfirmationDialog, { - body: this.env._t( - "Are you sure that you want to archive all the records from this column?" - ), + body: _t("Are you sure that you want to archive all the records from this column?"), confirm: async () => { await this.group.list.archive(); this.props.progressBarState?.updateCounts(this.group); @@ -151,11 +150,11 @@ export class KanbanHeader extends Component { deleteGroup() { this.dialog.add(ConfirmationDialog, { - body: this.env._t("Are you sure you want to delete this column?"), + body: _t("Are you sure you want to delete this column?"), confirm: async () => { this.props.deleteGroup(this.group); }, - confirmLabel: this.env._t("Delete"), + confirmLabel: _t("Delete"), cancel: () => {}, }); } @@ -167,7 +166,7 @@ export class KanbanHeader extends Component { context, resId: value, resModel: groupByField.relation, - title: this.env._t("Edit: %s", displayName), + title: _t("Edit: %s", displayName), onRecordSaved: async () => { await this.props.list.load(); this.props.list.model.notify(); diff --git a/addons/web/static/src/views/kanban/kanban_record.js b/addons/web/static/src/views/kanban/kanban_record.js index 56a31705484..ba0149dcfea 100644 --- a/addons/web/static/src/views/kanban/kanban_record.js +++ b/addons/web/static/src/views/kanban/kanban_record.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ColorList } from "@web/core/colorlist/colorlist"; import { evaluateBooleanExpr } from "@web/core/py_js/py"; import { Dropdown } from "@web/core/dropdown/dropdown"; @@ -304,7 +305,6 @@ export class KanbanRecord extends Component { * @param {Object} params */ triggerAction(params) { - const env = this.env; const { archInfo, openRecord, deleteRecord, record } = this.props; const { type } = params; switch (type) { @@ -330,7 +330,7 @@ export class KanbanRecord extends Component { ) { this.dialog.add(KanbanCoverImageDialog, { autoOpen, fieldName, record }); } else { - const warning = env._t( + const warning = _t( `Could not set the cover image: incorrect field ("%s") is provided in the view.`, fieldName ); @@ -339,7 +339,7 @@ export class KanbanRecord extends Component { break; } default: { - return this.notification.add(env._t("Kanban: no action for type: ") + type, { + return this.notification.add(_t("Kanban: no action for type: ") + type, { type: "danger", }); } diff --git a/addons/web/static/src/views/kanban/kanban_record_quick_create.js b/addons/web/static/src/views/kanban/kanban_record_quick_create.js index 43856b040ef..af2fa73a4b5 100644 --- a/addons/web/static/src/views/kanban/kanban_record_quick_create.js +++ b/addons/web/static/src/views/kanban/kanban_record_quick_create.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { useHotkey } from "@web/core/hotkeys/hotkey_hook"; import { useOwnedDialogs, useService } from "@web/core/utils/hooks"; @@ -148,8 +150,8 @@ class KanbanQuickCreateController extends Component { this.showFormDialogInError(e); } } else { - this.model.notification.add(this.model.env._t("Display Name"), { - title: this.model.env._t("Invalid fields: "), + this.model.notification.add(_t("Display Name"), { + title: _t("Invalid fields: "), type: "danger", }); } @@ -193,7 +195,7 @@ class KanbanQuickCreateController extends Component { this.addDialog(FormViewDialog, { resModel: this.props.resModel, context, - title: this.env._t("Create"), + title: _t("Create"), onRecordSaved: async (record) => { await this.props.onValidate(record.resId, "add"); await this.model.load(); diff --git a/addons/web/static/src/views/kanban/kanban_renderer.js b/addons/web/static/src/views/kanban/kanban_renderer.js index 926d96c743e..81eb886f83f 100644 --- a/addons/web/static/src/views/kanban/kanban_renderer.js +++ b/addons/web/static/src/views/kanban/kanban_renderer.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { DropdownItem } from "@web/core/dropdown/dropdown_item"; import { useHotkey } from "@web/core/hotkeys/hotkey_hook"; @@ -328,7 +329,7 @@ export class KanbanRenderer extends Component { if (this.exampleData && this.exampleData.ghostColumns) { colNames = this.exampleData.ghostColumns; } else { - colNames = [1, 2, 3, 4].map((num) => this.env._t("Column %s", num)); + colNames = [1, 2, 3, 4].map((num) => _t("Column %s", num)); } return colNames.map((colName) => ({ name: colName, diff --git a/addons/web/static/src/views/list/list_controller.js b/addons/web/static/src/views/list/list_controller.js index e05de8123fc..c0ac3a6a2c9 100644 --- a/addons/web/static/src/views/list/list_controller.js +++ b/addons/web/static/src/views/list/list_controller.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { download } from "@web/core/network/download"; import { evaluateExpr, evaluateBooleanExpr } from "@web/core/py_js/py"; @@ -307,14 +308,14 @@ export class ListController extends Component { isAvailable: () => this.isExportEnable, sequence: 10, icon: "fa fa-upload", - description: this.env._t("Export"), + description: _t("Export"), callback: () => this.onExportData(), }, archive: { isAvailable: () => this.archiveEnabled && !isM2MGrouped, sequence: 20, icon: "oi oi-archive", - description: this.env._t("Archive"), + description: _t("Archive"), callback: () => { this.dialogService.add(ConfirmationDialog, this.archiveDialogProps); }, @@ -323,14 +324,14 @@ export class ListController extends Component { isAvailable: () => this.archiveEnabled && !isM2MGrouped, sequence: 30, icon: "oi oi-unarchive", - description: this.env._t("Unarchive"), + description: _t("Unarchive"), callback: () => this.toggleArchiveState(false), }, delete: { isAvailable: () => this.activeActions.delete && !isM2MGrouped, sequence: 40, icon: "fa fa-trash-o", - description: this.env._t("Delete"), + description: _t("Delete"), callback: () => this.onDeleteSelectedRecords(), }, }; @@ -338,8 +339,8 @@ export class ListController extends Component { get archiveDialogProps() { return { - body: this.env._t("Are you sure that you want to archive all the selected records?"), - confirmLabel: this.env._t("Archive"), + body: _t("Are you sure that you want to archive all the selected records?"), + confirmLabel: _t("Archive"), confirm: () => { this.toggleArchiveState(true); }, @@ -449,7 +450,7 @@ export class ListController extends Component { if (import_compat) { exportedFields.unshift({ name: "id", - label: this.env._t("External ID"), + label: _t("External ID"), }); } await download({ @@ -517,11 +518,11 @@ export class ListController extends Component { const root = this.model.root; const body = root.isDomainSelected || root.selection.length > 1 - ? this.env._t("Are you sure you want to delete these records?") - : this.env._t("Are you sure you want to delete this record?"); + ? _t("Are you sure you want to delete these records?") + : _t("Are you sure you want to delete this record?"); return { body, - confirmLabel: this.env._t("Delete"), + confirmLabel: _t("Delete"), confirm: () => this.model.root.deleteRecords(), cancel: () => {}, }; diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 30f1ed8cd26..8b48f9b7b67 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -106,7 +106,7 @@ export class ListRenderer extends Component { this.creates = this.props.archInfo.creates.length ? this.props.archInfo.creates - : [{ type: "create", string: this.env._t("Add a line") }]; + : [{ type: "create", string: _t("Add a line") }]; this.cellToFocus = null; this.activeRowId = null; @@ -218,7 +218,7 @@ export class ListRenderer extends Component { } displaySaveNotification() { - this.notificationService.add(this.env._t('Please click on the "save" button first'), { + this.notificationService.add(_t('Please click on the "save" button first'), { type: "danger", }); } @@ -925,7 +925,6 @@ export class ListRenderer extends Component { } getGroupDisplayName(group) { - const { _t } = this.env; if (group.groupByField.type === "boolean") { return group.value === undefined ? _t("None") : group.value ? _t("Yes") : _t("No"); } else { diff --git a/addons/web/static/src/views/pivot/pivot_model.js b/addons/web/static/src/views/pivot/pivot_model.js index 29e0f94b8e8..d578d452382 100644 --- a/addons/web/static/src/views/pivot/pivot_model.js +++ b/addons/web/static/src/views/pivot/pivot_model.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Domain } from "@web/core/domain"; import { cartesian, sections, sortBy, symmetricalDifference } from "@web/core/utils/arrays"; import { KeepLast, Race } from "@web/core/utils/concurrency"; @@ -1178,7 +1179,7 @@ export class PivotModel extends Model { height: 1, measure: measure, originIndexes: [originIndex - 1, originIndex], - title: this.env._t("Variation"), + title: _t("Variation"), width: 1, }; if (isSortedByVariation && sortedColumn.originIndexes[1] === originIndex) { @@ -1200,7 +1201,6 @@ export class PivotModel extends Model { * @returns {Object[]} */ _getTableHeaders() { - const _t = this.env._t; const colGroupBys = this.metaData.fullColGroupBys; const height = colGroupBys.length + 1; const measureCount = this.metaData.activeMeasures.length; @@ -1292,9 +1292,7 @@ export class PivotModel extends Model { let rows = []; const group = tree.root; const rowGroupId = [group.values, []]; - const title = group.labels.length - ? group.labels[group.labels.length - 1] - : this.env._t("Total"); + const title = group.labels.length ? group.labels[group.labels.length - 1] : _t("Total"); const indent = group.labels.length; const isLeaf = !tree.directSubTrees.size; const rowGroupBys = this.metaData.fullRowGroupBys; @@ -1527,7 +1525,7 @@ export class PivotModel extends Model { } _getEmptyGroupLabel(fieldName) { - return this.env._t("None"); + return _t("None"); } /** @@ -1547,11 +1545,7 @@ export class PivotModel extends Model { metaData.fields[fieldName] && metaData.fields[fieldName].type === "boolean" ) { - return value === undefined - ? this.env._t("None") - : value - ? this.env._t("Yes") - : this.env._t("No"); + return value === undefined ? _t("None") : value ? _t("Yes") : _t("No"); } if (value === false) { return this._getEmptyGroupLabel(fieldName); diff --git a/addons/web/static/src/views/pivot/pivot_renderer.js b/addons/web/static/src/views/pivot/pivot_renderer.js index 0006009a699..ee398c716c2 100644 --- a/addons/web/static/src/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/views/pivot/pivot_renderer.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { CheckBox } from "@web/core/checkbox/checkbox"; import { localization } from "@web/core/l10n/localization"; import { registry } from "@web/core/registry"; @@ -157,7 +158,7 @@ export class PivotRenderer extends Component { onDownloadButtonClicked() { if (this.model.getTableWidth() > 16384) { throw new Error( - this.env._t( + _t( "For Excel compatibility, data cannot be exported if there are more than 16384 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures." ) ); diff --git a/addons/web/static/src/views/view_dialogs/export_data_dialog.js b/addons/web/static/src/views/view_dialogs/export_data_dialog.js index 05b2e7d6993..c1fc60063e9 100644 --- a/addons/web/static/src/views/view_dialogs/export_data_dialog.js +++ b/addons/web/static/src/views/view_dialogs/export_data_dialog.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { CheckBox } from "@web/core/checkbox/checkbox"; import { Dialog } from "@web/core/dialog/dialog"; @@ -99,9 +100,9 @@ export class ExportDataDialog extends Component { isSmall: this.env.isSmall, }); - this.title = this.env._t("Export Data"); - this.newTemplateText = this.env._t("New template"); - this.removeFieldText = this.env._t("Remove field"); + this.title = _t("Export Data"); + this.newTemplateText = _t("New template"); + this.removeFieldText = _t("Remove field"); this.debouncedOnResize = useDebounced(this.updateSize, 300); @@ -300,7 +301,7 @@ export class ExportDataDialog extends Component { async onSaveExportTemplate() { const name = this.exportListRef.el.value; if (!name) { - return this.notification.add(this.env._t("Please enter save field list name"), { + return this.notification.add(_t("Please enter save field list name"), { type: "danger", }); } @@ -337,12 +338,9 @@ export class ExportDataDialog extends Component { async onClickExportButton() { if (!this.state.exportList.length) { - return this.notification.add( - this.env._t("Please select fields to save export list..."), - { - type: "danger", - } - ); + return this.notification.add(_t("Please select fields to save export list..."), { + type: "danger", + }); } await this.props.download( this.state.exportList, @@ -353,7 +351,7 @@ export class ExportDataDialog extends Component { async onDeleteExportTemplate() { this.dialog.add(DeleteExportListDialog, { - text: this.env._t("Do you really want to delete this export template?"), + text: _t("Do you really want to delete this export template?"), delete: async () => { const id = Number(this.state.templateId); await this.orm.unlink("ir.exports", [id], { context: this.props.context }); diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 84c5b522328..6f2fce4f2cb 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { makeContext } from "@web/core/context"; import { useDebugCategory } from "@web/core/debug/debug_context"; @@ -883,7 +884,7 @@ function makeActionManager(env) { } else { const w = browser.open(url, "_blank"); if (!w || w.closed || typeof w.closed === "undefined") { - const msg = env._t( + const msg = _t( "A popup window has been blocked. You may need to change your " + "browser settings to allow popup windows for this page." ); @@ -1098,7 +1099,7 @@ function makeActionManager(env) { if (message) { env.services.notification.add(message, { sticky: true, - title: env._t("Report"), + title: _t("Report"), }); } if (!success) { @@ -1305,7 +1306,7 @@ function makeActionManager(env) { const view = _getView(viewType); if (!view) { throw new ViewNotFoundError( - env._t("No view of type '%s' could be found in the current action.", viewType) + _t("No view of type '%s' could be found in the current action.", viewType) ); } const newController = controller.action.controllers[viewType] || { diff --git a/addons/web/static/src/webclient/actions/client_actions.js b/addons/web/static/src/webclient/actions/client_actions.js index b1d1dbf2aac..01d4a415c36 100644 --- a/addons/web/static/src/webclient/actions/client_actions.js +++ b/addons/web/static/src/webclient/actions/client_actions.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { routeToUrl } from "@web/core/browser/router_service"; import { registry } from "@web/core/registry"; @@ -33,7 +34,7 @@ class InvalidAction extends Component { } onMounted() { - const message = this.env._t("No action with id '%s' could be found", this.props.actionId); + const message = _t("No action with id '%s' could be found", this.props.actionId); this.notification.add(message, { type: "danger" }); } } diff --git a/addons/web/static/src/webclient/actions/debug_items.js b/addons/web/static/src/webclient/actions/debug_items.js index ec4bf238512..d1197f2a593 100644 --- a/addons/web/static/src/webclient/actions/debug_items.js +++ b/addons/web/static/src/webclient/actions/debug_items.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { editModelDebug } from "@web/core/debug/debug_utils"; import { registry } from "@web/core/registry"; @@ -30,7 +31,7 @@ function editAction({ action, env }) { if (!action.id) { return null; } - const description = env._t("Edit Action"); + const description = _t("Edit Action"); return { type: "item", description, @@ -45,7 +46,7 @@ function viewFields({ action, env }) { if (!action.res_model) { return null; } - const description = env._t("View Fields"); + const description = _t("View Fields"); return { type: "item", description, @@ -77,7 +78,7 @@ function manageFilters({ action, env }) { if (!action.res_model) { return null; } - const description = env._t("Manage Filters"); + const description = _t("Manage Filters"); return { type: "item", description, @@ -105,7 +106,7 @@ function viewAccessRights({ accessRights, action, env }) { if (!action.res_model || !accessRights.canSeeModelAccess) { return null; } - const description = env._t("View Access Rights"); + const description = _t("View Access Rights"); return { type: "item", description, @@ -137,10 +138,10 @@ function viewRecordRules({ accessRights, action, env }) { if (!action.res_model || !accessRights.canSeeRecordRules) { return null; } - const description = env._t("Model Record Rules"); + const description = _t("Model Record Rules"); return { type: "item", - description: env._t("View Record Rules"), + description: _t("View Record Rules"), callback: async () => { const modelId = ( await env.services.orm.search("ir.model", [["model", "=", action.res_model]], { diff --git a/addons/web/static/src/webclient/clickbot/clickbot_loader.js b/addons/web/static/src/webclient/clickbot/clickbot_loader.js index 35b9ddb82c7..7c732e32d34 100644 --- a/addons/web/static/src/webclient/clickbot/clickbot_loader.js +++ b/addons/web/static/src/webclient/clickbot/clickbot_loader.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { loadJS } from "@web/core/assets"; import { registry } from "@web/core/registry"; @@ -11,7 +12,7 @@ export async function startClickEverywhere(xmlId, appsMenusOnly) { export function runClickTestItem({ env }) { return { type: "item", - description: env._t("Run Click Everywhere Test"), + description: _t("Run Click Everywhere Test"), callback: () => { startClickEverywhere(); }, @@ -21,7 +22,7 @@ export function runClickTestItem({ env }) { export default { startClickEverywhere, - runClickTestItem -} + runClickTestItem, +}; registry.category("debug").category("default").add("runClickTestItem", runClickTestItem); diff --git a/addons/web/static/src/webclient/debug_items.js b/addons/web/static/src/webclient/debug_items.js index 4014220a467..6704fdfa083 100644 --- a/addons/web/static/src/webclient/debug_items.js +++ b/addons/web/static/src/webclient/debug_items.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { browser } from "@web/core/browser/browser"; @@ -8,7 +10,7 @@ function runJSTestsItem({ env }) { const runTestsURL = browser.location.origin + "/web/tests?debug=assets"; return { type: "item", - description: env._t("Run JS Tests"), + description: _t("Run JS Tests"), href: runTestsURL, callback: () => { browser.open(runTestsURL); @@ -21,7 +23,7 @@ function runJSTestsMobileItem({ env }) { const runTestsMobileURL = browser.location.origin + "/web/tests/mobile?debug=assets"; return { type: "item", - description: env._t("Run JS Mobile Tests"), + description: _t("Run JS Mobile Tests"), href: runTestsMobileURL, callback: () => { browser.open(runTestsMobileURL); @@ -50,11 +52,11 @@ export function openViewItem({ env }) { return { type: "item", - description: env._t("Open View"), + description: _t("Open View"), callback: () => { env.services.dialog.add(SelectCreateDialog, { resModel: "ir.ui.view", - title: env._t("Select a view"), + title: _t("Select a view"), multiSelect: false, domain: [ ["type", "!=", "qweb"], diff --git a/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js b/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js index 03a3638129f..caf691b3754 100644 --- a/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js +++ b/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useAutofocus } from "@web/core/utils/hooks"; import { pick } from "@web/core/utils/objects"; import { formView } from "@web/views/form/form_view"; @@ -70,7 +71,7 @@ export class SettingsFormController extends formView.Controller { } displayName() { - return this.env._t("Settings"); + return _t("Settings"); } async beforeLeave() { @@ -117,7 +118,7 @@ export class SettingsFormController extends formView.Controller { let _continue = true; await new Promise((resolve) => { this.dialogService.add(SettingsConfirmationDialog, { - body: this.env._t("Would you like to save your changes?"), + body: _t("Would you like to save your changes?"), confirm: async () => { await this._save(); // It doesn't make sense to do the action of the button diff --git a/addons/web/static/src/webclient/user_menu/user_menu_items.js b/addons/web/static/src/webclient/user_menu/user_menu_items.js index 7a403717eca..e9fd8cb19b3 100644 --- a/addons/web/static/src/webclient/user_menu/user_menu_items.js +++ b/addons/web/static/src/webclient/user_menu/user_menu_items.js @@ -13,7 +13,7 @@ function documentationItem(env) { return { type: "item", id: "documentation", - description: env._t("Documentation"), + description: _t("Documentation"), href: documentationURL, callback: () => { browser.open(documentationURL, "_blank"); @@ -27,7 +27,7 @@ function supportItem(env) { return { type: "item", id: "support", - description: env._t("Support"), + description: _t("Support"), href: url, callback: () => { browser.open(url, "_blank"); @@ -75,7 +75,7 @@ export function preferencesItem(env) { return { type: "item", id: "settings", - description: env._t("Preferences"), + description: _t("Preferences"), callback: async function () { const actionDescription = await env.services.orm.call("res.users", "action_get"); actionDescription.res_id = env.services.user.userId; @@ -89,7 +89,7 @@ function odooAccountItem(env) { return { type: "item", id: "account", - description: env._t("My Odoo.com account"), + description: _t("My Odoo.com account"), callback: () => { env.services .rpc("/web/session/account") @@ -109,7 +109,7 @@ function logOutItem(env) { return { type: "item", id: "logout", - description: env._t("Log out"), + description: _t("Log out"), href: `${browser.location.origin}${route}`, callback: () => { browser.location.href = route; diff --git a/addons/web/static/tests/core/l10n/translation_tests.js b/addons/web/static/tests/core/l10n/translation_tests.js index c66c0d969e9..44ddb3275b5 100644 --- a/addons/web/static/tests/core/l10n/translation_tests.js +++ b/addons/web/static/tests/core/l10n/translation_tests.js @@ -82,17 +82,6 @@ QUnit.test("can lazy translate", async (assert) => { assert.strictEqual(target.innerText, "Bonjour"); }); -QUnit.test("_t is in env", async (assert) => { - assert.expect(1); - TestComponent.template = xml`
`; - serviceRegistry.add("localization", makeFakeLocalizationService()); - const env = await makeTestEnv(); - patchWithCleanup(translatedTerms, { ...terms }); - const target = getFixture(); - await mount(TestComponent, target, { env }); - assert.strictEqual(target.innerText, "Bonjour"); -}); - QUnit.test("luxon is configured in the correct lang", async (assert) => { await patchLang("fr_BE"); assert.strictEqual(DateTime.utc(2021, 12, 10).toFormat("MMMM"), "décembre"); diff --git a/addons/web/static/tests/helpers/mock_services.js b/addons/web/static/tests/helpers/mock_services.js index 9cd4713c195..fb7a95c0c35 100644 --- a/addons/web/static/tests/helpers/mock_services.js +++ b/addons/web/static/tests/helpers/mock_services.js @@ -5,7 +5,6 @@ import { browser } from "@web/core/browser/browser"; import { routerService } from "@web/core/browser/router_service"; import { effectService } from "@web/core/effects/effect_service"; import { localization } from "@web/core/l10n/localization"; -import { _t } from "@web/core/l10n/translation"; import { rpcService } from "@web/core/network/rpc_service"; import { ormService } from "@web/core/orm_service"; import { overlayService } from "@web/core/overlay/overlay_service"; @@ -42,7 +41,6 @@ export function makeFakeLocalizationService(config = {}) { return { name: "localization", start: async (env) => { - env._t = _t; return localization; }, }; diff --git a/addons/web/static/tests/helpers/utils.js b/addons/web/static/tests/helpers/utils.js index ff159d9c6b2..f799bcea230 100644 --- a/addons/web/static/tests/helpers/utils.js +++ b/addons/web/static/tests/helpers/utils.js @@ -7,6 +7,7 @@ import { download } from "@web/core/network/download"; import { Deferred } from "@web/core/utils/concurrency"; import { patch } from "@web/core/utils/patch"; import { isVisible } from "@web/core/utils/ui"; +import { _t } from "@web/core/l10n/translation"; import { registerCleanup } from "./cleanup"; import { App, onMounted, onPatched, useComponent } from "@odoo/owl"; @@ -729,7 +730,7 @@ export async function mount(Comp, target, config = {}) { props, }; if (env.services && "localization" in env.services) { - configuration.translateFn = env._t; + configuration.translateFn = _t; } const app = new App(Comp, configuration); registerCleanup(() => app.destroy()); diff --git a/addons/web/static/tests/legacy/helpers/test_env.js b/addons/web/static/tests/legacy/helpers/test_env.js index bdb820ec7f4..32799a960d4 100644 --- a/addons/web/static/tests/legacy/helpers/test_env.js +++ b/addons/web/static/tests/legacy/helpers/test_env.js @@ -25,27 +25,7 @@ setLoadXmlDefaultApp(app); } - const defaultTranslationParamters = { - code: "en_US", - date_format: '%m/%d/%Y', - decimal_point: ".", - direction: 'ltr', - grouping: [], - thousands_sep: ",", - time_format: '%H:%M:%S', - }; - - let _t; - if ('_t' in env) { - _t = Object.assign(env._t, {database: env._t.database || {}}) - } else { - _t = Object.assign(((s) => s), { database: {} }); - } - - _t.database.parameters = Object.assign(defaultTranslationParamters, _t.database.parameters); - const defaultEnv = { - _t, browser: Object.assign({ setTimeout: window.setTimeout.bind(window), clearTimeout: window.clearTimeout.bind(window), diff --git a/addons/web/static/tests/views/pivot_view_tests.js b/addons/web/static/tests/views/pivot_view_tests.js index 61aa1d2ed3f..58aa9b26e44 100644 --- a/addons/web/static/tests/views/pivot_view_tests.js +++ b/addons/web/static/tests/views/pivot_view_tests.js @@ -34,6 +34,7 @@ import { import { createWebClient, doAction } from "../webclient/helpers"; import { makeView } from "./helpers"; import { browser } from "@web/core/browser/browser"; +import { _t } from "@web/core/l10n/translation"; const serviceRegistry = registry.category("services"); @@ -405,7 +406,7 @@ QUnit.module("Views", (hooks) => { // this is important for export functionality. assert.strictEqual( pivot.model.metaData.title.toString(), - pivot.env._t("Untitled"), + _t("Untitled"), "should have a valid title" ); }); diff --git a/addons/web_editor/static/src/components/media_dialog/document_selector.js b/addons/web_editor/static/src/components/media_dialog/document_selector.js index 707e6baf3d7..1300967a446 100644 --- a/addons/web_editor/static/src/components/media_dialog/document_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/document_selector.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { Attachment, FileSelector, IMAGE_MIMETYPES } from './file_selector'; export class DocumentAttachment extends Attachment {} @@ -9,11 +10,11 @@ export class DocumentSelector extends FileSelector { setup() { super.setup(); - this.uploadText = this.env._t("Upload a document"); + this.uploadText = _t("Upload a document"); this.urlPlaceholder = "https://www.odoo.com/mydocument"; - this.addText = this.env._t("Add document"); - this.searchPlaceholder = this.env._t("Search a document"); - this.allLoadedText = this.env._t("All documents have been loaded"); + this.addText = _t("Add document"); + this.searchPlaceholder = _t("Search a document"); + this.allLoadedText = _t("All documents have been loaded"); } get attachmentsDomain() { diff --git a/addons/web_editor/static/src/components/media_dialog/file_selector.js b/addons/web_editor/static/src/components/media_dialog/file_selector.js index cec28eb796a..59b06911bd3 100644 --- a/addons/web_editor/static/src/components/media_dialog/file_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/file_selector.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { ConfirmationDialog } from '@web/core/confirmation_dialog/confirmation_dialog'; import { Dialog } from '@web/core/dialog/dialog'; @@ -14,9 +15,9 @@ export const IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.jpe', '.png', '.svg', '.gif' class RemoveButton extends Component { setup() { - this.removeTitle = this.env._t("This file is attached to the current record."); + this.removeTitle = _t("This file is attached to the current record."); if (this.props.model === 'ir.ui.view') { - this.removeTitle = this.env._t("This file is a public view attachment."); + this.removeTitle = _t("This file is a public view attachment."); } } @@ -29,7 +30,7 @@ RemoveButton.template = xml` { const prevented = await this.rpc('/web_editor/attachment/remove', { ids: [this.props.id], @@ -269,8 +270,8 @@ export class FileSelector extends Component { imageEl.onerror = () => { // This message is about the blob fetch failure. // It is only displayed if the fallback did not work. - this.notificationService.add(this.env._t("An error occurred while fetching the entered URL."), { - title: this.env._t("Error"), + this.notificationService.add(_t("An error occurred while fetching the entered URL."), { + title: _t("Error"), sticky: true, }); resolve(); diff --git a/addons/web_editor/static/src/components/media_dialog/icon_selector.js b/addons/web_editor/static/src/components/media_dialog/icon_selector.js index ef6f5b17b49..7ee690dea3b 100644 --- a/addons/web_editor/static/src/components/media_dialog/icon_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/icon_selector.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import fonts from '@web_editor/js/wysiwyg/fonts'; import { SearchMedia } from './search_media'; @@ -12,7 +13,7 @@ export class IconSelector extends Component { needle: '', }); - this.searchPlaceholder = this.env._t("Search a pictogram"); + this.searchPlaceholder = _t("Search a pictogram"); } get selectedMediaIds() { diff --git a/addons/web_editor/static/src/components/media_dialog/image_selector.js b/addons/web_editor/static/src/components/media_dialog/image_selector.js index bbe9669b312..6790e089992 100644 --- a/addons/web_editor/static/src/components/media_dialog/image_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/image_selector.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import weUtils from '@web_editor/js/common/utils'; import { Attachment, FileSelector, IMAGE_MIMETYPES, IMAGE_EXTENSIONS } from './file_selector'; @@ -60,12 +61,12 @@ export class ImageSelector extends FileSelector { this.state.showOptimized = false; this.NUMBER_OF_MEDIA_TO_DISPLAY = 10; - this.uploadText = this.env._t("Upload an image"); + this.uploadText = _t("Upload an image"); this.urlPlaceholder = "https://www.odoo.com/logo.png"; - this.addText = this.env._t("Add URL"); - this.searchPlaceholder = this.env._t("Search an image"); - this.urlWarningTitle = this.env._t("Uploaded image's format is not supported. Try with: " + IMAGE_EXTENSIONS.join(', ')); - this.allLoadedText = this.env._t("All images have been loaded"); + this.addText = _t("Add URL"); + this.searchPlaceholder = _t("Search an image"); + this.urlWarningTitle = _t("Uploaded image's format is not supported. Try with: " + IMAGE_EXTENSIONS.join(', ')); + this.allLoadedText = _t("All images have been loaded"); this.showOptimizedOption = this.env.debug; this.MIN_ROW_HEIGHT = 128; diff --git a/addons/web_editor/static/src/components/media_dialog/media_dialog.js b/addons/web_editor/static/src/components/media_dialog/media_dialog.js index 69753676f17..23ed79131b8 100644 --- a/addons/web_editor/static/src/components/media_dialog/media_dialog.js +++ b/addons/web_editor/static/src/components/media_dialog/media_dialog.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { Dialog } from '@web/core/dialog/dialog'; import { Notebook } from '@web/core/notebook/notebook'; @@ -37,7 +38,7 @@ export class MediaDialog extends Component { setup() { this.size = 'xl'; this.contentClass = 'o_select_media_dialog'; - this.title = this.env._t("Select a media"); + this.title = _t("Select a media"); this.rpc = useService('rpc'); this.orm = useService('orm'); diff --git a/addons/web_editor/static/src/components/media_dialog/video_selector.js b/addons/web_editor/static/src/components/media_dialog/video_selector.js index 89e96dfb594..c2e9985f52d 100644 --- a/addons/web_editor/static/src/components/media_dialog/video_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/video_selector.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { debounce } from '@web/core/utils/timing'; @@ -22,40 +23,40 @@ export class VideoSelector extends Component { this.OPTIONS = { autoplay: { - label: this.env._t("Autoplay"), - description: this.env._t("Videos are muted when autoplay is enabled"), + label: _t("Autoplay"), + description: _t("Videos are muted when autoplay is enabled"), platforms: [this.PLATFORMS.youtube, this.PLATFORMS.dailymotion, this.PLATFORMS.vimeo], urlParameter: 'autoplay=1', }, loop: { - label: this.env._t("Loop"), + label: _t("Loop"), platforms: [this.PLATFORMS.youtube, this.PLATFORMS.vimeo], urlParameter: 'loop=1', }, hide_controls: { - label: this.env._t("Hide player controls"), + label: _t("Hide player controls"), platforms: [this.PLATFORMS.youtube, this.PLATFORMS.dailymotion, this.PLATFORMS.vimeo], urlParameter: 'controls=0', }, hide_fullscreen: { - label: this.env._t("Hide fullscreen button"), + label: _t("Hide fullscreen button"), platforms: [this.PLATFORMS.youtube], urlParameter: 'fs=0', isHidden: () => this.state.options.filter(option => option.id === 'hide_controls')[0].value, }, hide_yt_logo: { - label: this.env._t("Hide Youtube logo"), + label: _t("Hide Youtube logo"), platforms: [this.PLATFORMS.youtube], urlParameter: 'modestbranding=1', isHidden: () => this.state.options.filter(option => option.id === 'hide_controls')[0].value, }, hide_dm_logo: { - label: this.env._t("Hide Dailymotion logo"), + label: _t("Hide Dailymotion logo"), platforms: [this.PLATFORMS.dailymotion], urlParameter: 'ui-logo=0', }, hide_dm_share: { - label: this.env._t("Hide sharing button"), + label: _t("Hide sharing button"), platforms: [this.PLATFORMS.dailymotion], urlParameter: 'sharing-enable=0', }, @@ -152,10 +153,10 @@ export class VideoSelector extends Component { const { embed_url: src, platform } = await this._getVideoURLData(url, options); if (!src) { - this.state.errorMessage = this.env._t("The provided url is not valid"); + this.state.errorMessage = _t("The provided url is not valid"); } else if (!platform) { this.state.errorMessage = - this.env._t("The provided url does not reference any supported video"); + _t("The provided url does not reference any supported video"); } else { this.state.errorMessage = ''; } diff --git a/addons/web_editor/static/src/js/backend/html_field.js b/addons/web_editor/static/src/js/backend/html_field.js index 9ae37d81b49..46b41988bd5 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -182,10 +182,10 @@ export class HtmlField extends Component { // generator. powerboxCommands: [ { - category: this.env._t('Marketing Tools'), - name: this.env._t('Dynamic Placeholder'), + category: _t('Marketing Tools'), + name: _t('Dynamic Placeholder'), priority: 10, - description: this.env._t('Insert personalized content'), + description: _t('Insert personalized content'), fontawesome: 'fa-magic', callback: () => { this.wysiwygRangePosition = getRangePosition(document.createElement('x'), this.wysiwyg.options.document || document); diff --git a/addons/web_tour/static/src/debug/debug_manager.js b/addons/web_tour/static/src/debug/debug_manager.js index 8d7fbc46b6f..f4c02fa79d8 100644 --- a/addons/web_tour/static/src/debug/debug_manager.js +++ b/addons/web_tour/static/src/debug/debug_manager.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; import ToursDialog from "@web_tour/debug/tour_dialog_component"; @@ -15,7 +16,7 @@ export function disableTours({ env }) { } return { type: "item", - description: env._t("Disable Tours"), + description: _t("Disable Tours"), callback: async () => { await env.services.orm.call("web_tour.tour", "consume", [activeTourNames]); for (const tourName of activeTourNames) { @@ -33,7 +34,7 @@ export function startTour({ env }) { } return { type: "item", - description: env._t("Start Tour"), + description: _t("Start Tour"), callback: async () => { env.services.dialog.add(ToursDialog); }, diff --git a/addons/web_unsplash/static/src/components/media_dialog/image_selector.js b/addons/web_unsplash/static/src/components/media_dialog/image_selector.js index c57c40346c6..e716dc7afef 100644 --- a/addons/web_unsplash/static/src/components/media_dialog/image_selector.js +++ b/addons/web_unsplash/static/src/components/media_dialog/image_selector.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { patch } from "@web/core/utils/patch"; import { KeepLast } from "@web/core/utils/concurrency"; import { MediaDialog, TABS } from '@web_editor/components/media_dialog/media_dialog'; @@ -52,16 +53,16 @@ patch(ImageSelector.prototype, { this.errorMessages = { 'key_not_found': { - title: this.env._t("Setup Unsplash to access royalty free photos."), + title: _t("Setup Unsplash to access royalty free photos."), subtitle: "", }, 401: { - title: this.env._t("Unauthorized Key"), - subtitle: this.env._t("Please check your Unsplash access key and application ID."), + title: _t("Unauthorized Key"), + subtitle: _t("Please check your Unsplash access key and application ID."), }, 403: { - title: this.env._t("Search is temporarily unavailable"), - subtitle: this.env._t("The max number of searches is exceeded. Please retry in an hour or extend to a better account."), + title: _t("Search is temporarily unavailable"), + subtitle: _t("The max number of searches is exceeded. Please retry in an hour or extend to a better account."), }, }; }, @@ -88,14 +89,14 @@ patch(ImageSelector.prototype, { if (this.errorMessages[this.state.unsplashError]) { return this.errorMessages[this.state.unsplashError].title; } - return this.env._t("Something went wrong"); + return _t("Something went wrong"); }, get errorSubtitle() { if (this.errorMessages[this.state.unsplashError]) { return this.errorMessages[this.state.unsplashError].subtitle; } - return this.env._t("Please check your internet connection or contact administrator."); + return _t("Please check your internet connection or contact administrator."); }, get selectedRecordIds() { @@ -243,8 +244,8 @@ patch(uploadService, { const file = service.addFile({ id: service.fileId, name: records.length > 1 ? - env._t("Uploading %s '%s' images.", records.length, records[0].query) : - env._t("Uploading '%s' image.", records[0].query), + _t("Uploading %s '%s' images.", records.length, records[0].query) : + _t("Uploading '%s' image.", records[0].query), size: null, progress: 0, }); diff --git a/addons/website/static/src/client_actions/website_preview/website_preview.js b/addons/website/static/src/client_actions/website_preview/website_preview.js index cea78b43e3d..29fa3a5925e 100644 --- a/addons/website/static/src/client_actions/website_preview/website_preview.js +++ b/addons/website/static/src/client_actions/website_preview/website_preview.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from '@web/core/browser/browser'; import { registry } from '@web/core/registry'; import { useService, useBus } from '@web/core/utils/hooks'; @@ -68,8 +69,8 @@ export class WebsitePreview extends Component { // really considered as the same domain, the user will share the // same session and CORS errors won't be a thing in such a case) this.dialogService.add(WebsiteDialog, { - title: this.env._t("Redirecting..."), - body: this.env._t("You are about to be redirected to the domain configured for your website ( %s ). This is necessary to edit or view your website from the Website app. You might need to log back in.", this.websiteDomain), + title: _t("Redirecting..."), + body: _t("You are about to be redirected to the domain configured for your website ( %s ). This is necessary to edit or view your website from the Website app. You might need to log back in.", this.websiteDomain), showSecondaryButton: false, }, { onClose: () => { diff --git a/addons/website/static/src/components/dialog/dialog.js b/addons/website/static/src/components/dialog/dialog.js index f3eece931e3..f41c33f9a7b 100644 --- a/addons/website/static/src/components/dialog/dialog.js +++ b/addons/website/static/src/components/dialog/dialog.js @@ -80,9 +80,9 @@ export class AddPageDialog extends Component { super.setup(); useAutofocus(); - this.title = this.env._t("New Page"); - this.primaryTitle = this.env._t("Create"); - this.switchLabel = this.env._t("Add to menu"); + this.title = _t("New Page"); + this.primaryTitle = _t("Create"); + this.switchLabel = _t("Add to menu"); this.website = useService('website'); this.orm = useService('orm'); this.http = useService('http'); diff --git a/addons/website/static/src/components/dialog/edit_menu.js b/addons/website/static/src/components/dialog/edit_menu.js index f75e8dceb0c..e80fdf10880 100644 --- a/addons/website/static/src/components/dialog/edit_menu.js +++ b/addons/website/static/src/components/dialog/edit_menu.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService, useAutofocus } from '@web/core/utils/hooks'; import wUtils from '@website/js/utils'; import { WebsiteDialog } from './dialog'; @@ -34,7 +35,7 @@ export class MenuDialog extends Component { setup() { this.rpc = useService('rpc'); this.website = useService('website'); - this.title = this.env._t("Add a menu item"); + this.title = _t("Add a menu item"); useAutofocus(); this.name = useControlledInput(this.props.name, value => !!value); @@ -106,8 +107,8 @@ export class EditMenuDialog extends Component { this.website = useService('website'); this.dialogs = useService('dialog'); - this.title = this.env._t("Edit Menu"); - this.saveButton = this.env._t("Save"); + this.title = _t("Edit Menu"); + this.saveButton = _t("Save"); this.menuEditor = useRef('menu-editor'); diff --git a/addons/website/static/src/components/dialog/page_properties.js b/addons/website/static/src/components/dialog/page_properties.js index cf426c14447..f7a9de7df7f 100644 --- a/addons/website/static/src/components/dialog/page_properties.js +++ b/addons/website/static/src/components/dialog/page_properties.js @@ -52,7 +52,7 @@ export class PageDependencies extends Component { showDependencies() { $(this.action.el).popover({ - title: this.env._t("Dependencies"), + title: _t("Dependencies"), boundary: 'viewport', placement: 'right', trigger: 'focus', @@ -79,9 +79,9 @@ PageDependencies.props = { export class DeletePageDialog extends Component { setup() { this.website = useService('website'); - this.title = this.env._t("Delete Page"); - this.deleteButton = this.env._t("Ok"); - this.cancelButton = this.env._t("Cancel"); + this.title = _t("Delete Page"); + this.deleteButton = _t("Ok"); + this.cancelButton = _t("Cancel"); this.state = useState({ confirm: false, diff --git a/addons/website/static/src/components/dialog/seo.js b/addons/website/static/src/components/dialog/seo.js index e9e7f560b22..50868352a07 100644 --- a/addons/website/static/src/components/dialog/seo.js +++ b/addons/website/static/src/components/dialog/seo.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { useService, useAutofocus } from '@web/core/utils/hooks'; import { MediaDialog } from '@web_editor/components/media_dialog/media_dialog'; import { WebsiteDialog } from './dialog'; @@ -321,9 +322,9 @@ class TitleDescription extends Component { return false; } if (this.seoContext.description.length < this.minRecommendedDescriptionSize) { - return this.env._t("Your description looks too short."); + return _t("Your description looks too short."); } else if (this.seoContext.description.length > this.maxRecommendedDescriptionSize) { - return this.env._t("Your description looks too long."); + return _t("Your description looks too long."); } return false; } @@ -368,8 +369,8 @@ export class OptimizeSEODialog extends Component { this.dialogs = useService('dialog'); this.orm = useService('orm'); - this.title = this.env._t("Optimize SEO"); - this.saveButton = this.env._t("Save"); + this.title = _t("Optimize SEO"); + this.saveButton = _t("Save"); this.size = 'lg'; this.contentClass = "oe_seo_configuration"; @@ -389,13 +390,13 @@ export class OptimizeSEODialog extends Component { // If website.page, hide the google preview & tell user his page is currently unindexed this.isIndexed = 'website_indexed' in this.data ? this.data.website_indexed : true; - this.seoNameHelp = this.env._t("This value will be escaped to be compliant with all major browsers and used in url. Keep it empty to use the default name of the record."); + this.seoNameHelp = _t("This value will be escaped to be compliant with all major browsers and used in url. Keep it empty to use the default name of the record."); this.previousSeoName = this.canEditUrl && this.data.seo_name; seoContext.seoName = this.previousSeoName; this.seoNameDefault = this.canEditUrl && this.data.seo_name_default; seoContext.description = this.getMeta({ name: 'description' }); - this.previewDescription = this.env._t("The description will be generated by search engines based on page content unless you specify one."); + this.previewDescription = _t("The description will be generated by search engines based on page content unless you specify one."); this.defaultTitle = this.getMeta({ name: 'default_title' }); seoContext.defaultTitle = this.defaultTitle; this.url = path; @@ -403,7 +404,7 @@ export class OptimizeSEODialog extends Component { seoContext.metaImage = this.data.website_meta_og_img || this.getMeta({ property: 'og:image' }); this.pageImages = this.getImages(); - this.socialPreviewDescription = this.env._t("The description will be generated by social media based on page content unless you specify one."); + this.socialPreviewDescription = _t("The description will be generated by social media based on page content unless you specify one."); this.hasSocialDefaultImage = this.data.has_social_default_image; this.canEditKeywords = 'website_meta_keywords' in this.data; diff --git a/addons/website/static/src/components/editor/editor.js b/addons/website/static/src/components/editor/editor.js index e70c7507943..e73b320997e 100644 --- a/addons/website/static/src/components/editor/editor.js +++ b/addons/website/static/src/components/editor/editor.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { WysiwygAdapterComponent } from '../wysiwyg_adapter/wysiwyg_adapter'; import { useActiveElement } from '@web/core/ui/ui_service'; @@ -103,8 +105,8 @@ export class WebsiteEditorComponent extends Component { * @returns {Promise} */ async reload({ snippetOptionSelector, url, invalidateSnippetCache } = {}) { - this.notificationService.add(this.env._t("Your modifications were saved to apply this option."), { - title: this.env._t("Content saved."), + this.notificationService.add(_t("Your modifications were saved to apply this option."), { + title: _t("Content saved."), type: 'success' }); if (invalidateSnippetCache) { diff --git a/addons/website/static/src/components/fields/publish_button.xml b/addons/website/static/src/components/fields/publish_button.xml index 1b362f26583..d435f7d8f1b 100644 --- a/addons/website/static/src/components/fields/publish_button.xml +++ b/addons/website/static/src/components/fields/publish_button.xml @@ -2,13 +2,17 @@ + Publish + Unpublish + Published + Unpublished
+ t-esc="props.record.data[props.name] ? unpublish : publish"/> + t-esc="props.record.data[props.name] ? published : unpublished"/>
diff --git a/addons/website/static/src/components/fields/redirect_field.js b/addons/website/static/src/components/fields/redirect_field.js index 0d09f8c56b7..ff44a2892a2 100644 --- a/addons/website/static/src/components/fields/redirect_field.js +++ b/addons/website/static/src/components/fields/redirect_field.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { pick } from "@web/core/utils/objects"; @@ -7,7 +8,7 @@ const { Component } = owl; class RedirectField extends Component { get info() { - return this.props.record.data[this.props.name] ? this.env._t("Published") : this.env._t("Unpublished"); + return this.props.record.data[this.props.name] ? _t("Published") : _t("Unpublished"); } onClick() { diff --git a/addons/website/static/src/components/translator/translator.js b/addons/website/static/src/components/translator/translator.js index e6ddb2e971a..01fb85cac34 100644 --- a/addons/website/static/src/components/translator/translator.js +++ b/addons/website/static/src/components/translator/translator.js @@ -1,4 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ + +import { _t } from "@web/core/l10n/translation"; import { useService } from '@web/core/utils/hooks'; import { WebsiteEditorComponent } from '../editor/editor'; import { WebsiteDialog } from '../dialog/dialog'; @@ -10,7 +12,7 @@ const localStorageNoDialogKey = 'website_translator_nodialog'; export class AttributeTranslateDialog extends Component { setup() { - this.title = this.env._t("Translate Attribute"); + this.title = _t("Translate Attribute"); this.formEl = useRef('form-container'); @@ -50,7 +52,7 @@ AttributeTranslateDialog.template = 'website.AttributeTranslateDialog'; // possible to interact with the content of `.o_translation_select` elements. export class SelectTranslateDialog extends Component { setup() { - this.title = this.env._t("Translate Selection Option"); + this.title = _t("Translate Selection Option"); this.inputEl = useRef('input'); this.optionEl = this.props.node; } @@ -79,8 +81,8 @@ SelectTranslateDialog.template = xml` export class TranslatorInfoDialog extends Component { setup() { - this.strongOkButton = this.env._t("Ok, never show me this again"); - this.okButton = this.env._t("Ok"); + this.strongOkButton = _t("Ok, never show me this again"); + this.okButton = _t("Ok"); } onStrongOkClick() { @@ -269,9 +271,9 @@ export class WebsiteTranslator extends WebsiteEditorComponent { styleEl.sheet.insertRule(`[data-oe-translation-state] {background: ${toTranslateColor} !important;}`); const showNotification = ev => { - let message = this.env._t('This translation is not editable.'); + let message = _t('This translation is not editable.'); if (ev.target.closest('.s_table_of_content_navbar_wrap')) { - message = this.env._t('Translate header in the text. Menu is generated automatically.'); + message = _t('Translate header in the text. Menu is generated automatically.'); } this.env.services.notification.add(message, { type: 'info', diff --git a/addons/website/static/src/components/views/page_list.js b/addons/website/static/src/components/views/page_list.js index 46cb261734a..b3902d5551f 100644 --- a/addons/website/static/src/components/views/page_list.js +++ b/addons/website/static/src/components/views/page_list.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import {PageControllerMixin, PageRendererMixin} from "./page_views_mixin"; import {registry} from '@web/core/registry'; import {listView} from '@web/views/list/list_view'; @@ -39,11 +40,11 @@ export class PageListController extends PageControllerMixin(listView.Controller) menuItems.publish = { sequence: 15, icon: "fa fa-globe", - description: this.env._t("Publish"), + description: _t("Publish"), callback: async () => { this.dialogService.add(ConfirmationDialog, { - title: this.env._t("Publish Website Content"), - body: this.env._t("%s record(s) selected, are you sure you want to publish them all?", this.model.root.selection.length), + title: _t("Publish Website Content"), + body: _t("%s record(s) selected, are you sure you want to publish them all?", this.model.root.selection.length), confirm: () => this.togglePublished(true), }); }, @@ -51,7 +52,7 @@ export class PageListController extends PageControllerMixin(listView.Controller) menuItems.unpublish = { sequence: 16, icon: "fa fa-chain-broken", - description: this.env._t("Unpublish"), + description: _t("Unpublish"), callback: async () => this.togglePublished(false), }; } diff --git a/addons/website/static/src/components/views/page_views_mixin.js b/addons/website/static/src/components/views/page_views_mixin.js index 6d9208d9f64..6f34de08413 100644 --- a/addons/website/static/src/components/views/page_views_mixin.js +++ b/addons/website/static/src/components/views/page_views_mixin.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import {AddPageDialog} from "../dialog/dialog"; import {useService} from "@web/core/utils/hooks"; @@ -22,7 +23,7 @@ export const PageControllerMixin = (component) => class extends component { this.dialog = useService('dialog'); this.rpc = useService('rpc'); - this.websiteSelection = odoo.debug ? [{id: 0, name: this.env._t("All Websites")}] : []; + this.websiteSelection = odoo.debug ? [{id: 0, name: _t("All Websites")}] : []; this.state = useState({ activeWebsite: undefined, diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 1378ebc0f5d..1d5815962c7 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -1,5 +1,6 @@ -/** @odoo-module */ +/** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import legacyEnv from '@web/legacy/js/common_env'; import { useService, useBus } from "@web/core/utils/hooks"; @@ -297,7 +298,7 @@ export class WysiwygAdapterComponent extends Wysiwyg { // primaryClick/secondaryClick props, so that closing the dialog // with "esc" or the top right cross icon also executes onStay. this.dialogs.add(WebsiteDialog, { - body: this.env._t("If you discard the current edits, all unsaved changes will be lost. You can cancel to return to edit mode."), + body: _t("If you discard the current edits, all unsaved changes will be lost. You can cancel to return to edit mode."), primaryClick: () => leaving = true, }, { onClose: () => { @@ -446,10 +447,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { .filter(':o_editable'); this.$editorMessageElement = $wrap.not('[data-editor-message]') .attr('data-editor-message-default', true) - .attr('data-editor-message', this.env._t('DRAG BUILDING BLOCKS HERE')); + .attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE')); $wrap.filter(':empty').attr('contenteditable', false); for (let htmlEl of $wrap.not("[placeholder]").filter('[data-oe-sanitize="no_block"]')) { - const placeholderText = this.env._t("Type in text here..."); + const placeholderText = _t("Type in text here..."); // Put the placeholder in the same location as the powerbox hint. htmlEl = htmlEl.querySelector("p, div") || htmlEl; htmlEl.setAttribute("placeHolder", placeholderText); @@ -626,10 +627,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }; const commands = [ { - category: this.env._t('Website'), - name: this.env._t('Alert'), + category: _t('Website'), + name: _t('Alert'), priority: 100, - description: this.env._t('Insert an alert snippet'), + description: _t('Insert an alert snippet'), fontawesome: 'fa-info', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -637,10 +638,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Rating'), + category: _t('Website'), + name: _t('Rating'), priority: 90, - description: this.env._t('Insert a rating snippet'), + description: _t('Insert a rating snippet'), fontawesome: 'fa-star-half-o', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -648,10 +649,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Card'), + category: _t('Website'), + name: _t('Card'), priority: 80, - description: this.env._t('Insert a card snippet'), + description: _t('Insert a card snippet'), fontawesome: 'fa-sticky-note', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -659,10 +660,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Share'), + category: _t('Website'), + name: _t('Share'), priority: 70, - description: this.env._t('Insert a share snippet'), + description: _t('Insert a share snippet'), fontawesome: 'fa-share-square-o', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -670,10 +671,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Text Highlight'), + category: _t('Website'), + name: _t('Text Highlight'), priority: 60, - description: this.env._t('Insert a text Highlight snippet'), + description: _t('Insert a text Highlight snippet'), fontawesome: 'fa-sticky-note', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -681,10 +682,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Chart'), + category: _t('Website'), + name: _t('Chart'), priority: 50, - description: this.env._t('Insert a chart snippet'), + description: _t('Insert a chart snippet'), fontawesome: 'fa-bar-chart', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -692,10 +693,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Progress Bar'), + category: _t('Website'), + name: _t('Progress Bar'), priority: 40, - description: this.env._t('Insert a progress bar snippet'), + description: _t('Insert a progress bar snippet'), fontawesome: 'fa-spinner', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -703,10 +704,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Badge'), + category: _t('Website'), + name: _t('Badge'), priority: 30, - description: this.env._t('Insert a badge snippet'), + description: _t('Insert a badge snippet'), fontawesome: 'fa-tags', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -714,10 +715,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Blockquote'), + category: _t('Website'), + name: _t('Blockquote'), priority: 20, - description: this.env._t('Insert a blockquote snippet'), + description: _t('Insert a blockquote snippet'), fontawesome: 'fa-quote-left', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { @@ -725,10 +726,10 @@ export class WysiwygAdapterComponent extends Wysiwyg { }, }, { - category: this.env._t('Website'), - name: this.env._t('Separator'), + category: _t('Website'), + name: _t('Separator'), priority: 10, - description: this.env._t('Insert an horizontal separator snippet'), + description: _t('Insert an horizontal separator snippet'), fontawesome: 'fa-minus', isDisabled: () => !this.odooEditor.isSelectionInBlockRoot(), callback: () => { diff --git a/addons/website/static/src/services/website_custom_menus.js b/addons/website/static/src/services/website_custom_menus.js index e649b432822..d4c4f4730b9 100644 --- a/addons/website/static/src/services/website_custom_menus.js +++ b/addons/website/static/src/services/website_custom_menus.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { EditMenuDialog } from '@website/components/dialog/edit_menu'; import { OptimizeSEODialog } from '@website/components/dialog/seo'; @@ -52,7 +53,7 @@ export const websiteCustomMenus = { // 'navbar menus' display system. filteredSections.push(...website.currentWebsite.metadata.contentMenus.map((menu, index) => ({ ...section, - name: env._t("Edit %s", menu[0]), + name: _t("Edit %s", menu[0]), dynamicProps: {rootID: parseInt(menu[1], 10)}, // Prevent a 't-foreach' duplicate key on menus template. id: `${section.id}-${index}`, diff --git a/addons/website/static/src/services/website_service.js b/addons/website/static/src/services/website_service.js index c90ee88dbab..bfbafa0b242 100644 --- a/addons/website/static/src/services/website_service.js +++ b/addons/website/static/src/services/website_service.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from '@web/core/registry'; import { loadLegacyWysiwygAssets } from '@web_editor/js/frontend/loader'; @@ -272,7 +273,7 @@ export const websiteService = { .catch(() => {}); } await modelNamesProm; - return modelNames[model] || env._t("Data"); + return modelNames[model] || _t("Data"); }, }; }, diff --git a/addons/website/static/src/systray_items/edit_website.js b/addons/website/static/src/systray_items/edit_website.js index 79dc67469bd..65c4d28b248 100644 --- a/addons/website/static/src/systray_items/edit_website.js +++ b/addons/website/static/src/systray_items/edit_website.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { useService } from '@web/core/utils/hooks'; @@ -33,9 +34,9 @@ class EditWebsiteSystray extends Component { get label() { if (this.translatable) { - return this.env._t("or edit master"); + return _t("or edit master"); } - return this.env._t("Edit"); + return _t("Edit"); } startEdit() { diff --git a/addons/website/static/src/systray_items/new_content.js b/addons/website/static/src/systray_items/new_content.js index 6a413e2e934..97bd56b144f 100644 --- a/addons/website/static/src/systray_items/new_content.js +++ b/addons/website/static/src/systray_items/new_content.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from '@web/core/registry'; import { useService } from '@web/core/utils/hooks'; import { WebsiteDialog, AddPageDialog } from "@website/components/dialog/dialog"; @@ -41,7 +42,7 @@ NewContentElement.defaultProps = { class InstallModuleDialog extends Component { setup() { - this.installButton = this.env._t("Install"); + this.installButton = _t("Install"); } onClickInstall() { @@ -63,10 +64,10 @@ export class NewContentModal extends Component { this.isSystem = this.user.isSystem; this.newContentText = { - failed: this.env._t('Failed to install "%s"'), - installInProgress: this.env._t("The installation of an App is already in progress."), - installNeeded: this.env._t('Do you want to install the "%s" App?'), - installPleaseWait: this.env._t('Installing "%s"'), + failed: _t('Failed to install "%s"'), + installInProgress: _t("The installation of an App is already in progress."), + installNeeded: _t('Do you want to install the "%s" App?'), + installPleaseWait: _t('Installing "%s"'), }; this.state = useState({ @@ -76,14 +77,14 @@ export class NewContentModal extends Component { moduleXmlId: 'base.module_website_blog', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Blog Post'), + title: _t('Blog Post'), }, { moduleName: 'website_event', moduleXmlId: 'base.module_website_event', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Event'), + title: _t('Event'), }, { moduleName: 'website_forum', @@ -91,35 +92,35 @@ export class NewContentModal extends Component { status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, redirectUrl: '/forum', - title: this.env._t('Forum'), + title: _t('Forum'), }, { moduleName: 'website_hr_recruitment', moduleXmlId: 'base.module_website_hr_recruitment', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Job Position'), + title: _t('Job Position'), }, { moduleName: 'website_sale', moduleXmlId: 'base.module_website_sale', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Product'), + title: _t('Product'), }, { moduleName: 'website_slides', moduleXmlId: 'base.module_website_slides', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Course'), + title: _t('Course'), }, { moduleName: 'website_livechat', moduleXmlId: 'base.module_website_livechat', status: MODULE_STATUS.NOT_INSTALLED, icon: xml``, - title: this.env._t('Livechat Widget'), + title: _t('Livechat Widget'), redirectUrl: '/livechat' }, ] @@ -216,7 +217,7 @@ export class NewContentModal extends Component { } return el; }); - this.website.showLoader({ title: this.env._t("Building your %s", name) }); + this.website.showLoader({ title: _t("Building your %s", name) }); try { await this.installModule(id, element.redirectUrl); } catch (error) { diff --git a/addons/website/static/src/systray_items/publish.js b/addons/website/static/src/systray_items/publish.js index 5f1284037a6..01038609012 100644 --- a/addons/website/static/src/systray_items/publish.js +++ b/addons/website/static/src/systray_items/publish.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { Switch } from '@website/components/switch/switch'; import { useService, useBus } from '@web/core/utils/hooks'; @@ -22,7 +23,7 @@ class PublishSystray extends Component { } get label() { - return this.state.published ? this.env._t("Published") : this.env._t("Unpublished"); + return this.state.published ? _t("Published") : _t("Unpublished"); } /** diff --git a/addons/website/static/src/systray_items/website_switcher.js b/addons/website/static/src/systray_items/website_switcher.js index 90f175cb84f..178ee43ce19 100644 --- a/addons/website/static/src/systray_items/website_switcher.js +++ b/addons/website/static/src/systray_items/website_switcher.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; @@ -30,12 +31,12 @@ export class WebsiteSwitcherSystray extends Component { this.websiteService.goToWebsite({ websiteId: website.id }); if (!website.domain) { const closeFn = this.notificationService.add( - this.env._t( + _t( "This website does not have a domain configured. To avoid unexpected behaviours during website edition, we recommend closing (or refreshing) other browser tabs.\nTo remove this message please set a domain in your website settings" ), { type: "warning", - title: this.env._t( + title: _t( "No website domain configured for this website." ), sticky: true, diff --git a/addons/website_sale/static/src/js/website_sale_reorder.js b/addons/website_sale/static/src/js/website_sale_reorder.js index 405dbc4864b..80bfbb2e410 100644 --- a/addons/website_sale/static/src/js/website_sale_reorder.js +++ b/addons/website_sale/static/src/js/website_sale_reorder.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { debounce as debounceFn } from "@web/core/utils/timing"; import publicWidget from "@web/legacy/js/public/public_widget"; import { localization as l10n } from "@web/core/l10n/localization"; @@ -159,7 +160,7 @@ export class ReorderDialog extends Component { getWarningForProduct(product) { if (!product.add_to_cart_allowed) { - return this.env._t("This product is not available for purchase."); + return _t("This product is not available for purchase."); } return false; } @@ -192,7 +193,7 @@ export class ReorderDialog extends Component { if (this.cartQty) { // Open confirmation modal this.dialogService.add(ReorderConfirmationDialog, { - body: this.env._t("Do you wish to clear your cart before adding products to it?"), + body: _t("Do you wish to clear your cart before adding products to it?"), confirm: async () => { await this.rpc("/shop/cart/clear"); await onConfirm(); diff --git a/addons/website_sale/static/src/xml/website_sale_reorder_modal.xml b/addons/website_sale/static/src/xml/website_sale_reorder_modal.xml index 18af2cf9521..afa165cd473 100644 --- a/addons/website_sale/static/src/xml/website_sale_reorder_modal.xml +++ b/addons/website_sale/static/src/xml/website_sale_reorder_modal.xml @@ -1,7 +1,8 @@ - + Re-Order + diff --git a/addons/website_sale_stock/static/src/js/website_sale_reorder.js b/addons/website_sale_stock/static/src/js/website_sale_reorder.js index 1eca1459b6d..7a34c796482 100644 --- a/addons/website_sale_stock/static/src/js/website_sale_reorder.js +++ b/addons/website_sale_stock/static/src/js/website_sale_reorder.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ReorderDialog } from "@website_sale/js/website_sale_reorder"; import { patch } from "@web/core/utils/patch"; @@ -32,7 +33,7 @@ patch(ReorderDialog.prototype, { product.add_to_cart_allowed = false; } if (product.max_quantity_available < product.qty) { - product.qty_warning = this.env._t( + product.qty_warning = _t( "You ask for %s Units but only %s are available.", product.qty.toFixed(1), product.max_quantity_available.toFixed(1) @@ -40,7 +41,7 @@ patch(ReorderDialog.prototype, { product.qty = product.max_quantity_available; product.stock_warning = true; } else if (product.combinationInfo.cart_qty) { - product.qty_warning = this.env._t( + product.qty_warning = _t( "You already have %s Units in your cart.", product.combinationInfo.cart_qty.toFixed(1) ); @@ -52,7 +53,7 @@ patch(ReorderDialog.prototype, { */ getWarningForProduct(product) { if (product.hasOwnProperty("max_quantity_available") && !product.max_quantity_available) { - return this.env._t("This product is out of stock."); + return _t("This product is out of stock."); } return super.getWarningForProduct(...arguments); }, @@ -62,7 +63,7 @@ patch(ReorderDialog.prototype, { */ changeProductQty(product, newQty) { if (product.max_quantity_available && newQty > product.max_quantity_available) { - product.qty_warning = this.env._t( + product.qty_warning = _t( "You ask for %s Units but only %s are available.", newQty.toFixed(1), product.max_quantity_available.toFixed(1)