Vue-I18n

Integrate vue-i18n with Odoo.

12.0

https://hub.konvergo.app/web/image/product.template/1461/image_1920?unique=b438357
  • Odoo Version

Description

Vue-I18n

This module integrates Vue I18n with the frontend assets of Odoo.

Usage Example

This example requires that you master of the following topics:

  • Creating a Vuejs application with VueI18n
  • Creating a Odoo javascript extension

Creating a VueI18n instance

In a file app.js, define your Vue application.

require("web.dom_ready");

if (!$("#my_app_node").length) {
  return $.Deferred().reject("DOM doesn't contain '#my_app_node'");
}

const i18nFactory = require("vue_i18n.i18nFactory");
i18nFactory.setLang("fr_FR")

const i18n = i18nFactory.makeI18n();
const app = new Vue({i18n}).$mount('#my_app_node');

Inside other javascript files, you may register your messages:

const i18nFactory = require("vue_i18n.i18nFactory");
i18nFactory.addMessages(
    {
        en: {
            foo: "bar",
        },
        fr_FR: {
            foo: "baz",
        },
    }
)

Known Issues

The module does not define how to get the language of the user.

In the example above, it is hardcoded to "fr_FR".

Getting the current user's language from the frontend point of view in Odoo is not trivial. You may not merely call navigator.language.

Contributors

More information


License
Technical Name
Log In to view
Version
12.0