1 Reply Latest reply on Jan 30, 2013 11:43 PM by Ove Lindström

    CQ, CQ.i18n is not Defined | Publish Instance | CQ 5.4

    mailtovinay11

      Hi,

       

      We are using OOTB CQ.i18n.getMessage for localized JQuery Messages. everything is working as expected on Auhor instances but on Publish , it is throwing CQ is not Defined, CQ.i18n is not defined JAVA SCRIPT Errors.

       

      Code e.g.

      email: CQ.I18n.getMessage("APP201")

       

      Do we need to enable any extra JS call or include any JS file into the clientlibs? Any pointers to this would be apreciated.

       

       

      Thanks

      Vinay

        • 1. Re: CQ, CQ.i18n is not Defined | Publish Instance | CQ 5.4
          Ove Lindström Level 4

          In author, you are running "inside of the CQ environment", and then the client libraries that defines and communicates with the CQ instance in initiated. On publish, you are running the scripts on the client machine. That environment has no idea about CQ.i18n, since that call does not generate a REST call to the server. It is different execution envrionments.

           

          Solution: Have a block in the server side generated code that fills a js object with the correct translations or create a REST/JSON representation of the i18n-nodes.

           

          Taking Alex and Vinzenz perfect answer from the Google Group (https://groups.google.com/forum/?fromgroups=#!topic/day-communique/EZxBdGUwcQU).

           

          For CQ5.5

          For publish, you need to explicitly include the "cq.shared" clientlib. On author this is automatically part of the authoring UI javascript. 
          
          The clientlibs are noted as part of the js docs: http://dev.day.com/content/docs/en/cq/current/widgets-api/index.html?class=CQ.I18n (see basic info at the top, right below the class name). 
          
          

           

          Disclaimer for CQ5.4

           

          In CQ 5.4 the i18n utility class was not yet part of the clientlib "cq.shared" but of "cq.widgets". You would have to load latter but this is not recommended on a publish instance since it is rather big 
          (containing all the widgets required for page authoring and admin consoles). You probably would have to extract the i18n part and for example add it to "cq.shared" manually.
          
          

           

          Message was edited by: Ove Lindström Excelent answer.