Interface TranslationManager


  • public interface TranslationManager
    The TranslationManager maintains a list of installed TranslationServiceFactory instances within the system. These are registered with the Manager at activation and must contain a unique "FactoryName" identifier. The TranslationManager is obtained via the normal OSGi service registry. This service creates TranslationService instances using the respective factories via one of the "createTranslationService()" methods below.
    • Method Detail

      • isTranslationServiceConfigured

        boolean isTranslationServiceConfigured​(Resource resource)
                                        throws TranslationException
        Checks if the given resource has any translation service specified, and all the properties are set correctly. it returns false if translation service is not correctly configured or return true otherwise
        Parameters:
        resource - resource
        Returns:
        boolean
        Throws:
        TranslationException - the translation exception
      • createTranslationService

        @Deprecated
        TranslationService createTranslationService​(java.lang.String factoryName)
                                             throws TranslationException
        Deprecated.
        Creates a TranslationService instance registered with the given translation factory name. TranslationManager returns the TranslationService instance From within a JSP for example: TranslationManager tm = sling.getService(TranslationManager.class); TranslationService translationService = tm.createTranslationService(resource); Or from within a Component/Service you would import the TranslationManager Object:
        Parameters:
        factoryName - the translation factory name
        Returns:
        the TranslationService instance
        Throws:
        TranslationException - the translation exception
      • createTranslationService

        @Deprecated
        TranslationService createTranslationService​(java.lang.String factoryName,
                                                    TranslationConstants.TranslationMethod translationMethod,
                                                    java.lang.String strCloudConfigPath)
                                             throws TranslationException
        Deprecated.
        since 2.4.0, use createTranslationService(String, TranslationMethod, String, Resource) instead. Creates a TranslationService instance registered with the given translation factory name. TranslationManager returns the TranslationService instance From within a JSP for example: TranslationManager tm = sling.getService(TranslationManager.class); TranslationService translationService = tm.createTranslationService(factoryName, translationMethod, strCloudConfigPath); Or from within a Component/Service you would import the TranslationManager Object:
        Parameters:
        factoryName - the translation factory name
        translationMethod - the translation method
        strCloudConfigPath - path to cloud config, if this value is null, then factory name is used. This cloud config is passed to service factory.
        Returns:
        the TranslationService instance
        Throws:
        TranslationException - the translation exception
      • createTranslationService

        default TranslationService createTranslationService​(java.lang.String factoryName,
                                                            TranslationConstants.TranslationMethod translationMethod,
                                                            java.lang.String strCloudConfigPath,
                                                            Resource resource)
                                                     throws TranslationException
        Creates a TranslationService instance registered with the given translation factory name. TranslationManager returns the TranslationService instance. For example: TranslationManager tm = sling.getService(TranslationManager.class); TranslationService translationService = tm.createTranslationService(resource, factoryName, translationMethod, strCloudConfigPath); Or you can import TranslationManager Object:
        Parameters:
        factoryName - the translation factory name
        translationMethod - the translation method
        strCloudConfigPath - path to cloud config, if this value is null, then factory name is used. This cloud config is passed to service factory.
        resource - context-aware resource, containing the content to be translated.
        Returns:
        the TranslationService instance
        Throws:
        TranslationException - the translation exception
      • createTranslationService

        TranslationService createTranslationService​(Resource resource)
                                             throws TranslationException
        Creates a TranslationService instance based upon logic determined by the properties of the passed in resource. The Translation configuration logic is used to determine which properties to base the decision off of (Content Path, Content Category, Provider Name stored on content). By default a configured factory name (TranslationConstants.TN_FACTORY_NAME) takes precedence. If no Connector can be determined the system default TranslationService will be returned.
        Parameters:
        resource - The resource of a content node containing the content to be translated.
        Returns:
        the TranslationService instance
        Throws:
        TranslationException - the translation exception
      • createPostEditService

        TranslationService createPostEditService​(Resource resource)
                                          throws TranslationException
        Creates a TranslationService instance based upon logic determined by the properties of the passed in resource. The Translation configuration logic is used to determine which properties to base the decision off of (Content Path, Content Category, Provider Name stored on content). If no Connector can be determined return null.
        Parameters:
        resource - The resource of a content node containing the content to be translated.
        Returns:
        the TranslationService instance
        Throws:
        TranslationException - the translation exception
      • getAvailableFactoryNames

        @Deprecated
        java.util.Map<java.lang.String,​java.lang.String> getAvailableFactoryNames()
                                                                                 throws TranslationException
        Deprecated.
        CreatePostEditService is used as part of an asynchronous translation process. A Post Edit Service may be included in a translation workflow. This would normally happen after a synchronous translation service. to improve the quality of a machine translation. The Post Edit service defines the human asyncronous translation service to be used via a connector to this service. A connector using asynchronous translation is required for a Post Edit Service.
        Returns:
        Map<String, String> containing currently installed factories (<Factory Name, Factory Label>)
        Throws:
        TranslationException - the translation exception
      • getAvailableFactoryNames

        java.util.Map<java.lang.String,​java.lang.String> getAvailableFactoryNames​(TranslationConstants.TranslationMethod translationMethod)
                                                                                 throws TranslationException
        Returns a Map of the currently available TranslationServiceFactories The service returns both the factory name and a factory label for use in drop downs based on TranslationMethod. This saves us from having to make a second call (per factory) to getLabel(); As noted: the factory names (the ID) is the KEY and the factory label is the VALUE. This is the value that can be displayed when factory will show up in UI. The return is a MAP<NAME, LABEL> of factories within the system.
        Parameters:
        translationMethod - Use TranslationMethod parameter to filter out services and return only those factories which support this translation method. Pass null to return all installed factories.
        Returns:
        Map<String, String> containing currently installed factories (<Factory Name, Factory Label>)
        Throws:
        TranslationException - the translation exception