Interface TranslationContext

    • Method Detail

      • getRenderPurpose

        @NotNull
        RenderPurpose getRenderPurpose()
        Get the reason this format rendering is being performed
        Returns:
        RenderPurpose for current rendering
      • getTranslationStore

        @NotNull
        MutableDataHolder getTranslationStore()
        Get MutableDataHolder for storing this translation run values across render purpose phases
      • transformNonTranslating

        @NotNull
        java.lang.CharSequence transformNonTranslating​(@Nullable
                                                       java.lang.CharSequence prefix,
                                                       @NotNull
                                                       java.lang.CharSequence nonTranslatingText,
                                                       @Nullable
                                                       java.lang.CharSequence suffix,
                                                       @Nullable
                                                       java.lang.CharSequence suffix2)
        Transform non-translating text

        During RenderPurpose.TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED this returns the original non-translating text for the nonTranslatingText (placeholder)

        Parameters:
        prefix - prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        nonTranslatingText - non-rendering text of the node (content will depend on translation phase)
        suffix - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        suffix2 - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        Returns:
        text to be used in rendering for this phase
      • postProcessNonTranslating

        void postProcessNonTranslating​(@NotNull
                                       java.util.function.Function<java.lang.String,​java.lang.CharSequence> postProcessor,
                                       @NotNull
                                       java.lang.Runnable scope)
        Parameters:
        postProcessor - id post processor for TRANSLATED purpose
        scope - code to which the post processor applies
      • postProcessNonTranslating

        @NotNull
        <T> T postProcessNonTranslating​(@NotNull
                                        java.util.function.Function<java.lang.String,​java.lang.CharSequence> postProcessor,
                                        @NotNull
                                        java.util.function.Supplier<T> scope)
        Parameters:
        postProcessor - id post processor for TRANSLATED purpose
        scope - code to which the post processor applies
      • isPostProcessingNonTranslating

        boolean isPostProcessingNonTranslating()
        Returns:
        true if non-translating post processor is set
      • transformTranslating

        @NotNull
        java.lang.CharSequence transformTranslating​(@Nullable
                                                    java.lang.CharSequence prefix,
                                                    @NotNull
                                                    java.lang.CharSequence translatingText,
                                                    @Nullable
                                                    java.lang.CharSequence suffix,
                                                    @Nullable
                                                    java.lang.CharSequence suffix2)
        Transform translating text but which is contextually isolated from the text block in which it is located ie. link reference or image reference

        During RenderPurpose.TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id and adds it to translation snippets During RenderPurpose.TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED this returns the translated text for the translatingText (placeholder)

        Parameters:
        prefix - prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        translatingText - translating but isolated text of the node (content will depend on translation phase)
        suffix - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        suffix2 - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        Returns:
        text to be used in rendering for this phase
      • transformAnchorRef

        @NotNull
        java.lang.CharSequence transformAnchorRef​(@NotNull
                                                  java.lang.CharSequence pageRef,
                                                  @NotNull
                                                  java.lang.CharSequence anchorRef)
        During RenderPurpose.TRANSLATION_SPANS this converts anchorRef to ordinal placeholder id During RenderPurpose.TRANSLATED_SPANS this returns the ordinal placeholder During RenderPurpose.TRANSLATED this returns new anchorRef for the AnchorRefTarget original was referring to
        Parameters:
        pageRef - url part without the anchor ref to resolve reference
        anchorRef - anchor ref
        Returns:
        anchorRef for the phase to be used for rendering
      • translatingRefTargetSpan

        void translatingRefTargetSpan​(@Nullable
                                      Node target,
                                      @NotNull
                                      TranslatingSpanRender render)
        Separate translation span which is also a ref target
        Parameters:
        target - target node,
        render -
      • customPlaceholderFormat

        void customPlaceholderFormat​(@NotNull
                                     TranslationPlaceholderGenerator generator,
                                     @NotNull
                                     TranslatingSpanRender render)
        Temporarily change the format for placeholders
        Parameters:
        generator - placeholder generator
        render - render which will be used with the custom generator