From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/mail/static/src/models/locale/locale.js | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 addons/mail/static/src/models/locale/locale.js (limited to 'addons/mail/static/src/models/locale') diff --git a/addons/mail/static/src/models/locale/locale.js b/addons/mail/static/src/models/locale/locale.js new file mode 100644 index 00000000..50167f07 --- /dev/null +++ b/addons/mail/static/src/models/locale/locale.js @@ -0,0 +1,52 @@ +odoo.define('mail/static/src/models/locale/locale.js', function (require) { +'use strict'; + +const { registerNewModel } = require('mail/static/src/model/model_core.js'); +const { attr } = require('mail/static/src/model/model_field.js'); + +function factory(dependencies) { + + class Locale extends dependencies['mail.model'] { + + //---------------------------------------------------------------------- + // Private + //---------------------------------------------------------------------- + + /** + * @private + * @returns {string} + */ + _computeLanguage() { + return this.env._t.database.parameters.code; + } + + /** + * @private + * @returns {string} + */ + _computeTextDirection() { + return this.env._t.database.parameters.direction; + } + + } + + Locale.fields = { + /** + * Language used by interface, formatted like {language ISO 2}_{country ISO 2} (eg: fr_FR). + */ + language: attr({ + compute: '_computeLanguage', + }), + textDirection: attr({ + compute: '_computeTextDirection', + }), + }; + + Locale.modelName = 'mail.locale'; + + return Locale; +} + +registerNewModel('mail.locale', factory); + +}); -- cgit v1.2.3