Sharath Madappa
Sharath Madappa

Reputation: 3402

i18n translations do not work when error page is inluded by ACS commons error page handler

The i18n part of error page does not work when response from the error page designated by the errorPages property is included by the error page handler.

The translations work fine when the error page is requested directly . However it fails to pick up any values and falls back to the key when the response of the error page is included by includeUsingGET method

Example :

com.day.cq.i18n.I18n i18n = new com.day.cq.i18n.I18n(slingRequest.getResourceBundle(currentPage.getLanguage(false))); String translatedValue = i18n.get("key"); out.write(translatedValue);

  1. Output when error page is accessed directly with a get request -> translatedValue

  2. Output when the error page is included by errorpagehandler on a 404 -> key

The value of currentPage.getLanguage(false).getLanguage() is same in both the cases.

NOTE : I have already created an issue on github regarding this, asking a question here as stackoverflow has larger audience.

Upvotes: 1

Views: 1117

Answers (4)

ronnyfm
ronnyfm

Reputation: 2081

Just edit your org.apache.sling.i18n.impl.I18NFilter.config, adding the following line (without spaces):

sling.filter.scope=["REQUEST","ERROR"]

Upvotes: 1

Georgii Goriachev
Georgii Goriachev

Reputation: 61

Please, try add config /apps/sling/config/org.apache.sling.i18n.impl.I18NFilter.xml.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   jcr:primaryType="sling:OsgiConfig"
   service.ranking="-10000"
   sling.filter.scope="[REQUEST,ERROR]"/>

Also you can do this config in the "Adobe Experience Manager Web Console Configuration" (http://example.com:4502/system/console/configMgr).

Upvotes: 3

Sharath Madappa
Sharath Madappa

Reputation: 3402

As Rampant says , it is a Bug with the application and has nothing to do with ACS-commons error page handler. The bug was in Sling (link) , i18n filter which loads the correct resourceBundle was not firing for error scope. The issue has been corrected in r1430633. Looks like this fix hasn't made its way to 5.6.1 yet. A workaround for dealing with it can be found at https://forums.adobe.com/message/5012581.

Upvotes: 0

Brenn
Brenn

Reputation: 1384

At least in version 5.5 we encountered this problem for any page that resulted in an error page getting loaded. We did not find a good solution. This goes beyond the ACS commons error page and seems to be an issue internal to CQ5.

You are likely going to have to write your own code to load the bundle OUTSIDE of the sling request. I would suggest writing your own OSGI service for this and calling that instead of the the slingRequest.getResourceBundle() approach.

Upvotes: 1

Related Questions