2 Replies Latest reply on Jul 1, 2015 7:06 AM by shipra

    Plugin i18Text not getting rendered.

    shipra

      Hello,

       

      I am creating a widget in which I need to make it multilingual.

      I have placed the key value pair in plugin_i18n.properties file.

       

      Path:src/main/resources

      Value put in the file:

      custom.defaultMessage=Enter The Location

       

      I want to access this key from a js file which is in widget:

       

      var defaultMessage = {i18nText('custom.defaultMessage')};

      I am getting following error:

       

      "Uncaught SyntaxError: Unexpected string"

       

      I tried to display the key value from FTL:

      <span>{i18nText('custom.defaultMessage')}</span>

       

      output:{i18nText('custom.defaultMessage')}

       

      Can anyone let me know whats going wrong???

       

      I have done the same things in theme before.

      Used custom key.JIVE key but never faced any issue there.

       

      Ryan Rutan Nils Heuer

        • Re: Plugin i18Text not getting rendered.
          Himanshu.Dhuper

          The JS string messages are not directly read from properties file as you have mentioned in above snippet, unless you have a Jquery plugin like this added in your file jquery.i18n.properties.js.

           

          Solution :

          Within the scope of your above code, you can define a div or a span(with display: none) like this in your FTL or soy file :


          1) <div class="custom-message" id="custom-msg" style="display:none"><@s.text name="custom.defaultMessage" /></div>

           

          2) Next, invoke this in your JS function like to show the div :

          $j(function() {

            $j("#custom-msg").show();

            </#if>


          3)  In your plugin_i18n.properties file, define your localized string which will be read in your FTL/Soy and later the same div/span will show up in JS.

           

          Please post your findings if that works !

           

          Cheers !

            • Re: Plugin i18Text not getting rendered.
              shipra

              Thanks Himanshu!

               

              worked like a charm.

               

              I am running into a new issue when I drag this widget more then once in the same page.

              I feel there is some js conflict happening. Have you come across a similar issue?

               

              If I drag the widgets then the panel of widgets is not getting loaded. There is no error in the console nor in sbs.logs.

               

              I am getting few warnings:

              3 scripts on this page are included more than once.

              Object/7.0.2.0/resources/scripts/post.js:

              2/plugins/ClockWidget/resources/script/AutoComplete.js:

              2/plugins/WorkFlowPlugin/resources/script/jquery.tablesorter_2_11.js:

              2__proto__: Object

              css_selector_counter.js:30 Stylesheet selector count,

              4012, is approaching the 4095 selector limit in IE.

              /7.0.2.0/styles/jive.css

               

              debug.js:82 Module was requested but is missing. commentMacroApps

              debug.js:82 Module was requested but is missing. forumMacroDiscussionApp

              1109 console messages are not shown.

               

              debug.js:82 Module was requested but is missing. separateScripts-dep-1435759483903-1 (This comes when I click on customize)