Hello Community,
I want to create i18n object to get i18n key value. In my java class i don't have access to request object. How can i create i18n object to get i18n key inside my java class.
Please suggest
Regards,
Vinay
Solved! Go to Solution.
Views
Replies
Total Likes
You can get the resource bundle without the request object by calling the Sling ResourceBundleProvider API.
//Get the reference of bundle provider to get the resource bundle. @Reference(target="(component.name=org.apache.sling.i18n.impl.JcrResourceBundleProvider)") private ResourceBundleProvider resourceBundleProvider;
See the API docs for more details - https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/org/apache/sling/i18n/ResourceBundleProvider.html
Views
Replies
Total Likes
You can get the resource bundle without the request object by calling the Sling ResourceBundleProvider API.
//Get the reference of bundle provider to get the resource bundle. @Reference(target="(component.name=org.apache.sling.i18n.impl.JcrResourceBundleProvider)") private ResourceBundleProvider resourceBundleProvider;
See the API docs for more details - https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/org/apache/sling/i18n/ResourceBundleProvider.html
Views
Replies
Total Likes
Hi,
One approach I can think of is as below :
import com.day.cq.i18n.I18n;
I18n.get(getRequest(), "i18key")
Views
Replies
Total Likes
Thanks for the reply . I will try this approach.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies