I have been trying to access the message bundle for existing widgets, i.e. Legend. The instructions are clear on creating and accessing your own custom widget bundles, however, I need to access the locale specific label for an existing widget. What do I use for the BundleID for @arcgis/core/widgets/Legend as an example?
Thanks,
René
Solved! Go to Solution.
Sorry, the locales for existing widgets are not extensible at this time.
Sorry, the locales for existing widgets are not extensible at this time.
Ok, thanks René.
I was looking into it because when the widget is wrapped in an Expand, only the expandTooltip is shown on hover (title) and results to the default ("Expand" in En, and "Développer" in Fr). I was hoping to capture the label from the widget to override using expandTooltip() so that a user with a screen reader will be able to read the widget label instead.
If that's the case, you can do something like this.
view.when(() => {
bgExpand.expandTooltip = `${bgExpand.label} ${basemapGallery.label}`;
});
I think this will help get you there.
https://codepen.io/odoe/pen/powJRyM?editors=1000
The widget labels will change with locales, so you can update the expandTooltip from another widget. You do need to widget.watch("label", method) or wait for view.when() to get the labels.
Yes, that looks good... Thanks!
After doing more research, a quick hack is to do the following:
import esriConfig from "@arcgis/core/config.js";
import * as intl from "@arcgis/core/intl";
export function functionName() {
var lang = intl.getLocale().toLowerCase().slice(0, 2);
var widgetsAssetsPath = esriConfig.assetsPath + "/esri/widgets/";
var legendT9n = `${widgetsAssetsPath}${widget.widget_id}/t9n/${widget.widget_id}_${lang}.json`;
var t9n = {widgetLabel: "Layer List"}; // Default value
returnConfig(legendT9n).then(t9nResults => {
if(t9nResults){
t9n = t9nResults;
}
}).then(function (){
console.log(t9n.widgetLabel);
});
Just something for now so I don't have to define the labels elsewhere...