Translating Widget Descriptions Using Metadata Plugin (Linux)
Translating Widget Descriptions Using Metadata Plugin (Linux)
This article explains how to translate the description section of widgets within a Sisense dashboard using the metadata translations plugin. This functionality allows users to customize descriptions based on language preferences, making dashboards more accessible to a global audience.
[ALT Text: Dashboard with two gauges: left shows total revenue at 14.48M, right shows total units sold at 32,386. Blue tones and numeric indicators.]
Step-by-Step Guide
The metadata translations plugin enables translation of various metadata, but translating widget descriptions requires an additional logic. The example code snippet is provided below:
const config = { "en-US": { "datasourceAliasing": { "tables": {}, "formulas": {}, "columns": {}, "widgets": {}, "descriptions": { "Custom Widget description": "Custom Widget description", "Some other description": "Some description" } } }, "fr-FR": { "datasourceAliasing": { "tables": {}, "formulas": {}, "columns": {}, "widgets": {}, "descriptions": { "Custom Widget description": "Description du widget personnalisé", "Some test": "Quelques essais" } } } }; function getDescriptionMapping() { // get current user language const currentUserLanguage = $$get(prism, 'user.preferences.language') || $$get(prism, 'user.preferences.localeId') // get descriptions from config for this currentUserLanguage // return mapping } function translateDescription(descriptions, widget) { widget.desc = widget.desc.replaceAll(desc, descriptions[desc]); } prism.on("dashboardloaded", function(e, args) { const descriptionMapping = getDescriptionMapping(); // iterate all widgets and translate descriptions that match the ones from the config args.dashboard.widgets.$$widgets.forEach(function(w) { translateDescription(descriptionMapping, w) }); })
Adjust the code snippet as necessary to fit specific needs or languages. Due to variability in user setups, slight modifications may be necessary.
Please find the implementation example attached to this article along with the dashboard based on the sample ElastiCube.
Conclusion
Translating widget descriptions enhances the usability of dashboards by catering to users' language preferences. Users can implement a translation mechanism using the metadata translations plugin following the steps provided.
References/ Related Content
- Sisense Community: Metadata Plugin Grouping Provider Example
- Sisense Documentation: Metadata Translations Plugin Guide
Disclaimer: This post outlines a potential custom workaround for a specific use case or provides instructions regarding a specific task. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. If you need further assistance with this, please let us know.