Localize a custom widget (eSearch) added to portal

1256
5
Jump to solution
01-07-2021 07:50 AM
Labels (2)
MattiasEkström
Occasional Contributor III

Hi!

Anyone know how to localize a custom widget?

I've downloded @RobertScheitlin__GISP s eSearch and copied it to my own webserver and registered it to my Portal. All works great, thanks Robert for a great widget with so much config possibilities.

Now I want to translate it into Swedish, I went into the nls-folder and since there already was localizations for french and dutch i just copied the fr-folder and renamed it to swedish and then went ahead to translate the strings.js in my sv-folder. I also changed "sv": 0, to "sv": 1 in this part in the main strings.js

  "ro": 0,
  "ru": 0,
  "sv": 1,
  "th": 0,
  "tr": 0,

Still my swedish strings doesn't show up. The rest of the web app and widgets are in swedish so nothing wrong with my browser language settings. And i've re-registered the widget to my portal with no luck.

Am I missing something?

I don't have to let it be avalible in english so I guess I could change the main strings.js instead, but it would be better to do this "the right way".

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mattias,

   You did exactly what you needed to do to get the localization to be Swedish. Maybe you are having a cache issue. I don't do Portal so all I can say is that it just did this in WAB Dev and it worked fine.

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Emeritus

Mattias,

   You did exactly what you needed to do to get the localization to be Swedish. Maybe you are having a cache issue. I don't do Portal so all I can say is that it just did this in WAB Dev and it worked fine.

MattiasEkström
Occasional Contributor III

Back to work after the weekend and the eSearch widget is translated to Swedish! Must have been a cache issue then. Note to self: rember to clear cache when not seeing any updates. 😀

0 Kudos
MattiasEkström
Occasional Contributor III

@RobertScheitlin__GISP  some follow-up... Translating strings should not affect any functionality right?

But when using my swedish strings I can't open the general settings in the configuration, I get this error in the console

Uncaught Error: dijit._WidgetsInTemplateMixin: parser returned unfilled promise (probably waiting for module auto-load), unsupported by _WidgetsInTemplateMixin. Must pre-load all supporting widgets before instantiation.

Is the general settigs module in any way related to it's name in the strings.js?

When removing my swedish localization it works again. 

 

I was also going to test the widget in WAB Developer version, but when I add the widget by clicking OK in the settings window I get this error message

TypeError: widgetJson.manifest[("i18nLabels_featureAction_" + action.name)] is undefined

And the widget is not added to the application. Do you have any idea what it could be due to? This happens whether I have my localization or not. The manifest.json looks like this:

{
  "name": "eSearch",
  "label": "Enhanced Search",
  "platform": "HTML",
  "version": "2.13",
  "wabVersion": "2.16",
  "author": "Robert Scheitlin & Esri R&D Center Beijing",
  "description": "This enhanced search widget offers the ability to search by a string, geometry and spatial relationship.",
  "copyright": "2019",
  "license": "http://www.apache.org/licenses/LICENSE-2.0",
  "properties": {
    "hasVersionManager": true
  },
  "featureActions": [
    {
      "name": "eShowStatistics",
      "uri": "featureActions/eShowStatistics"
    }, {
      "name": "eZoomTo",
      "uri": "featureActions/eZoomTo"
    }
  ]
}

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I have seen this happen when syntax errors are made in the the Strings.js file. A single quote needs to escaped with a backslash before it. You can see this in the French locale file.

MattiasEkström
Occasional Contributor III

Tried to escape the single quotes but it didn't work, but removing all singel quotes worked. And that works for me. Thanks!

0 Kudos