You can create a plugin in Visual Builder that supports multiple languages.
Multilanguage is natively supported in Visual Builder, which lets you build and maintain a
single plugin for users speaking different languages. For more information, see Create a Multilanguage Application in Oracle Visual
Builder: Create a Language Switcher.
-
Add the ofsConnector.js and ofsInitConnector.js files into your plugin as
described in the Build Your Application Using Oracle Visual Builder Studio
section.
-
Add the following code to the ofsInitConnector file to apply a new language to
the plugin:
setUserLocale(user)
{
const currentLocale = window.localStorage.getItem('ofs_plugin_locale');
const locale = user.locale || user.languageCode || window.navigator.language;
if (currentLocale !== locale) {
window.localStorage.setItem('ofs_plugin_locale', locale);
window.location.href = this.getPluginUrl();
}
}
You can send the
locale field through the Plugin API in the init
message; the field belongs to the user collection. You can use it to apply
the language selected in the
Oracle Fusion Field Service UI to the
plugin. This code snippet shows the
locale field in the init
message:
{
...,
"user": {
"languageCode": "en",
"locale": "en-US"
}
}