Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Disable i18n translation in dialogs

Avatar

Level 3

Hello,

I would like to disable i18n translation in dialogs. I have the situation where I load the options for a dropdown dynamically, from a servlet. The options are exactly how they should appear in the dropdown. However, CQ seems to do some additional translation for the options. Is there a way to disable this?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

For 5.6 - overlay that and replace use of that without that logic that translates it. 

Can you post a screenshot too. I have never heard of this happening before. 

View solution in original post

13 Replies

Avatar

Level 4

Can you explain a little more what CQ is changing because I have worked on a similar scenario but never faced such an issue. A little more detail might help.

Thanks,

Samir

Avatar

Level 3

Let's say I have an option text called "change". In case a label called "change" exists, then the translated value of the label "change" will be used in the dropdown. 

Everything is fine as long as labels having the exact same value as the "text" property do not exist.

Avatar

Level 10

See this community article: 

https://helpx.adobe.com/experience-manager/using/dialog_fields_servlets.html

The values in the drop down are the same values returned by the servlet. CQ does not attempt to translate these values. 

Avatar

Level 10

It would be helpful if you tell which code you are using to populate drop down..

Avatar

Level 3

This is the dialog:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Dialog"> <items jcr:primaryType="cq:Widget" xtype="tabpanel"> <items jcr:primaryType="cq:WidgetCollection"> <app-properties jcr:primaryType="cq:Panel" title="App Properties"> <items jcr:primaryType="cq:WidgetCollection"> <type jcr:primaryType="cq:Widget" fieldLabel="App Version" name="./version" type="select" defaultValue="" xtype="selection" optionsRoot="." optionsTextField="value" optionsValueField="key" options="$PATH.versions.json"/> </items> </app-properties> </items> </items> </jcr:root> 

The results retrieved by $PATH.versions.json are correct. However something happens when they are present in the dialog...

The servlet result is:

[{"key":"","value":"(Empty)"},{"key":"v_1","value":"v_1"}]

However, because there is a label for v_1 with the value test for English, then instead of showing a dropdown with options: (Empty) and v_1, a dropdown with options (Empty) and test will be displayed.

Avatar

Level 10

See the community article and the dialog in it - notice the values returned by the servlet - you will never get translated values using that code. 

Avatar

Level 3

Thanks for the answer. However, I don't think it's related to the server side code. As I said, the returned results are correct. The problem is somewhere on the front end side.

Avatar

Level 10

I have never seen this before - this is not a configurable setting that can be set. Can you post a screen shot of what you are seeing. 

Avatar

Level 3

Hmm, I think I'll test this on a fresh project. It might be some custom implementation on our project that I am not aware of. I noticed that in the widgets documentation

https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.shared.HTTP it is mentioned that the values will be passed to CQ.Util.formatData (which uses translation) in case optionsRoot does not exist. However, I do have an optionsRoot property. I did some debugging on the widgets.js file and it doesn't call that function, just as it is documented.

I'll do some testing and let you know. Thanks for the quick replies.

Avatar

Level 10

Let us know the results of your testing. 

Avatar

Level 3

After more debugging, it looks like the translation happens in the setOptions function of Selection.js, line 419:

for (var i = 0; i < options.length; i++) { var o = options[i]; storeConfig.data.push([o.value, o.text, CQ.I18n.getVarMessage(o[CQ.shared.XSS.getXSSPropertyName("text")]), o.qtip]); }

 

I am using CQ 5.6. 

Avatar

Correct answer by
Level 10

For 5.6 - overlay that and replace use of that without that logic that translates it. 

Can you post a screenshot too. I have never heard of this happening before. 

Avatar

Level 3

Sure,

So here is the dialog:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Dialog"> <items jcr:primaryType="cq:Widget" xtype="tabpanel"> <items jcr:primaryType="cq:WidgetCollection"> <app-properties jcr:primaryType="cq:Panel" title="App Properties"> <items jcr:primaryType="cq:WidgetCollection"> <type jcr:primaryType="cq:Widget" fieldLabel="App Version" name="./version" type="select" defaultValue="" xtype="selection" optionsRoot="." optionsTextField="value" optionsValueField="key" options="$PATH.versions.json"/> </items> </app-properties> </items> </items> </jcr:root>

I've hardcoded the options values in the versions.jsp file to simplify testing. Bellow are the results of $PATH.versions.jsp:

Bellow is the setup of the i18n label:

Bellow is the code snippet that does the translation:

for (var i = 0; i < options.length; i++) { var o = options[i]; storeConfig.data.push([o.value, o.text, CQ.I18n.getVarMessage(o[CQ.shared.XSS.getXSSPropertyName("text")]), o.qtip]); }

And here is the result:

 

Yeah, I was thinking of doing the same as you suggested i.e. overlay the Selection.js file.