Question about Localization and Expand widget - ArcGIS Maps SDK for JavaScript 4.25

505
2
Jump to solution
01-27-2023 06:27 AM
Egge-Jan_Pollé
MVP Regular Contributor

Hi all,

I have a little question about Localization when using the Expand widget. Actually, I have asked the same question way back in 2019, and I got a satisfactory answer at the time from @KellyHutchins. The solution provided back then worked in the JS API 4.11 but stopped working a few releases later (4.17? 4.18?).

But the issue remains, so I am searching for an alternative solution.

Issue:

I love this Localization in the JavaScript Maps SDK, with the SDK automatically using the locale of the browser. So, in my case everything is showing in Dutch. Cool.

Now I have a little issue: I like my widgets to be collapsed, so I have put my Search widget within an Expand widget. The question is about localization when using the Expand widget: the expandTooltip defaults to "Expand" for English locale, whereas I want it to read "Search" or "Find address or place". I can modify the expandTooltip, but then I will loose the advantages of localization.

So, is there a way to replace the hard coded "Find address or place" with a string that will be localized?

expandTooltip: "Find address or place",‍‍ // loss of localization :-(‍

The solution given at the time was to use the searchWidget.label (and, as I said, this worked like a charm in 4.11) like this:

expandTooltip: searchWidget.label, // "Search" in stead of the default "Expand" for English locale‍‍

But not anymore... so, how would I solve this issue in 4.25?

Thanks in advance for your help,

Egge-Jan

0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

Yes, you can still do the same thing. Just make sure the search widget has loaded before you assign it to the expandToolTip.

Here's an example: https://codepen.io/bsvensson/pen/gOjKeKa?editors=1000 

View solution in original post

0 Kudos
2 Replies
BjornSvensson
Esri Regular Contributor

Yes, you can still do the same thing. Just make sure the search widget has loaded before you assign it to the expandToolTip.

Here's an example: https://codepen.io/bsvensson/pen/gOjKeKa?editors=1000 

0 Kudos
Egge-Jan_Pollé
MVP Regular Contributor

OK. Cool. Thanks for your swift reply 🙂

Previously (in 4.11) it worked directly, without the need to wait for the widget to be loaded. But apparently the library has grown to such a level of complexity that this additional step is needed.

Thanks again. Will go and apply this new knowledge immediately.

0 Kudos