summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/locale
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/models/locale')
-rw-r--r--addons/mail/static/src/models/locale/locale.js52
1 files changed, 52 insertions, 0 deletions
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);
+
+});