Hi @Ronnie09
To get the language for Experience Fragments and Content Fragments, you can follow a similar approach as you did for pages. You can access the language information through the JCR properties of the fragment's node.
For Experience Fragment:
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
// ...
Resource experienceFragmentResource = ... // Get the experience fragment resource
ResourceResolver resourceResolver = experienceFragmentResource.getResourceResolver();
String language = resourceResolver.getLanguage(experienceFragmentResource.getPath());
For Content Fragment:
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
// ...
Resource contentFragmentResource = ... // Get the content fragment resource
ResourceResolver resourceResolver = contentFragmentResource.getResourceResolver();
String language = resourceResolver.getLanguage(contentFragmentResource.getPath());
These code snippets demonstrate how to get the language for Experience Fragments and Content Fragments by using the ResourceResolver to get the language based on the resource's path.