I18n Sling Models Injector

Available since version 4.0.0

Purpose

Allows for Sling Models classes and interfaces to be injected with I18n objects and / or values.

Injections are available when adapting either a Resource or SlingHttpServletRequest object. Note: Out of performance reasons, only the I18n can be injected using the generic @Inject. The String values need to be annotated with @I18N.

Example

@Model(adaptables = { SlingHttpServletRequest.class, Resource.class })
public class TestModel {

    @I18N
    private I18n i18n;

    @I18N("com.adobe.i18n.backButtonText")
    private String backButtonText
    
    @PostConstruct
    public void init(){
        String text = i18n.get("com.adobe.i18n.backButtonText");
        //do something
    }
    
    public String getBackButtonText() {
        return backButtonText;
    }
}