I've created a custom widget in web appbuilder developer edition. I can add it to an app within web appbuilder without issue but when I try to launch the app I get an "i18nLabels is undefined" error.
Has anyone encountered this?
What does your nls/strings.js file look like?
This is what I've got:
Try removing the parenthesis from "root". The documentation strings file looks like this
define({ root:{ label1: "I am a demo widget.", label2: "This is configurable." }, "zh-cn": true });
I don't have any other languages in my app so far, so mine just looks like this.
define({ root: { allSelections: "All selections", appliedChanges: "Successfully applied changes", appliedFailed: "Applied failed!", //etc } // add supported locales below: // , "zh-cn": true });
. You don't need to add all the language options until you have created their appropriate strings files.
Still getting the error. I only added all the language options because I was getting the error and thought I needed them.
As for the parenthesis in root. I removed it but it did not change anything. Funny thing is that I got that file from the CustomWidgetTemplate in samplewidgets. They all seem to have those parenthesis but as you note the doc says otherwise.
Is your file structure like what's shown on this page?
How are you using the nls variables in you Widget.html or Widget.js files?
Here are the examples from my widget:
Widget.html
<div data-dojo-attach-point="btnSignIn" id="signinbtn" class="jimu-btn apply" data-dojo-attach-event="onclick:signIn"> ${nls.signin} </div>
Widget.js
resultMessage = this.nls.allSelections;
I have no variables in my nls/strings.js. Just the _widgetLabel and two _featureAction_.
I'm really not sure what is going on. Thanks for your help though.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.