Open dhardtke opened 3 years ago
Okay, so I have spent the last hour trying to write or rather fix the current tests after changing the getLanguageRoot(resource, respectContent)
call.
The problem is that https://github.com/wcm-io/wcm-io-testing/blob/develop/aem-mock/core/src/main/java/io/wcm/testing/mock/aem/MockLanguageManager.java throws an UnsupportedOperationException
in that method and I believe this mock service is used in the tests. I can not verify this because I have never been able to run the tests from within my IntelliJ and can't debug them.
I am also unable to provide a custom MockLanguageManager
by manually registering it using context.registerService(LanguageManager.class, new MockLanguageManager());
: Can anyone help me out here?
Bug Report
Current Behavior We have a client that would like to use language roots that use the country name as page name, e.g. "us". The current implementation of the Experience Fragment does not take the content into account because it invokes https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/api/LanguageManager.html#getLanguageRoot-org.apache.sling.api.resource.Resource- which only looks at the Page name ("us" in my example) and, hence, returns
null
.Expected behavior/code The code should use https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/api/LanguageManager.html#getLanguageRoot-org.apache.sling.api.resource.Resource-boolean- which allows taking the "Language Root" checkbox into account:
Environment
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
): openjdk version "11.0.11" 2021-04-20Possible Solution I will create a Pull Request that changes the call of the LanguageManager:
https://github.com/adobe/aem-core-wcm-components/blob/ac9c4a05ab44a979765db5bd9f0f7c3afc51571e/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/util/LocalizationUtils.java#L82
Additional context / Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.