Interface TranslationContext
- All Known Subinterfaces:
NodeFormatterContext, TranslationHandler, TranslationHandlerFactory
- All Known Implementing Classes:
Formatter.MainNodeFormatter, Formatter.MainNodeFormatter.SubNodeFormatter, NodeFormatterSubContext, TranslationHandlerImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoidcustomPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render) Temporarily change the format for placeholders@Nullable HtmlIdGenerator@Nullable MergeContext@NotNull RenderPurposeGet the reason this format rendering is being performed@NotNull MutableDataHolderGet MutableDataHolder for storing this translation run values across render purpose phasesbooleanbooleanReturns false if special translation functions are no-opsvoidnonTranslatingSpan(@NotNull TranslatingSpanRender render) Separate non-translation span.voidpostProcessNonTranslating(@NotNull Function<String, CharSequence> postProcessor, @NotNull Runnable scope) <T> TpostProcessNonTranslating(@NotNull Function<String, CharSequence> postProcessor, @NotNull Supplier<T> scope) @NotNull CharSequencetransformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef) DuringRenderPurpose.TRANSLATION_SPANSthis converts anchorRef to ordinal placeholder id DuringRenderPurpose.TRANSLATED_SPANSthis returns the ordinal placeholder DuringRenderPurpose.TRANSLATEDthis returns new anchorRef for the AnchorRefTarget original was referring to@NotNull CharSequencetransformNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence nonTranslatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) Transform non-translating text@NotNull CharSequencetransformTranslating(@Nullable CharSequence prefix, @NotNull CharSequence translatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) Transform translating text but which is contextually isolated from the text block in which it is located ie.voidtranslatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render) Separate translation span which is also a ref targetvoidtranslatingSpan(@NotNull TranslatingSpanRender render) Separate translation span.
-
Method Details
-
getIdGenerator
-
getRenderPurpose
Get the reason this format rendering is being performed- Returns:
- RenderPurpose for current rendering
-
getTranslationStore
Get MutableDataHolder for storing this translation run values across render purpose phases -
isTransformingText
boolean isTransformingText()Returns false if special translation functions are no-opsDuring
RenderPurpose.TRANSLATION_SPANSthis is true DuringRenderPurpose.TRANSLATED_SPANSthis is true DuringRenderPurpose.TRANSLATEDthis is true- Returns:
- true if need to call translation related functions
-
transformNonTranslating
@NotNull @NotNull CharSequence transformNonTranslating(@Nullable @Nullable CharSequence prefix, @NotNull @NotNull CharSequence nonTranslatingText, @Nullable @Nullable CharSequence suffix, @Nullable @Nullable CharSequence suffix2) Transform non-translating textDuring
RenderPurpose.TRANSLATION_SPANSthis converts text to non-translating placeholder based on ordinal id DuringRenderPurpose.TRANSLATED_SPANSthis returns the non-translating placeholder based on ordinal id DuringRenderPurpose.TRANSLATEDthis 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 parsingnonTranslatingText- 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 parsingsuffix2- 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 @NotNull Function<String, CharSequence> postProcessor, @NotNull @NotNull Runnable scope) - Parameters:
postProcessor- id post processor for TRANSLATED purposescope- code to which the post processor applies
-
postProcessNonTranslating
@NotNull <T> T postProcessNonTranslating(@NotNull @NotNull Function<String, CharSequence> postProcessor, @NotNull @NotNull Supplier<T> scope) - Parameters:
postProcessor- id post processor for TRANSLATED purposescope- code to which the post processor applies
-
isPostProcessingNonTranslating
boolean isPostProcessingNonTranslating()- Returns:
- true if non-translating post processor is set
-
transformTranslating
@NotNull @NotNull CharSequence transformTranslating(@Nullable @Nullable CharSequence prefix, @NotNull @NotNull CharSequence translatingText, @Nullable @Nullable CharSequence suffix, @Nullable @Nullable CharSequence suffix2) Transform translating text but which is contextually isolated from the text block in which it is located ie. link reference or image referenceDuring
RenderPurpose.TRANSLATION_SPANSthis converts text to non-translating placeholder based on ordinal id and adds it to translation snippets DuringRenderPurpose.TRANSLATED_SPANSthis returns the non-translating placeholder based on ordinal id DuringRenderPurpose.TRANSLATEDthis 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 parsingtranslatingText- 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 parsingsuffix2- 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 @NotNull CharSequence transformAnchorRef(@NotNull @NotNull CharSequence pageRef, @NotNull @NotNull CharSequence anchorRef) DuringRenderPurpose.TRANSLATION_SPANSthis converts anchorRef to ordinal placeholder id DuringRenderPurpose.TRANSLATED_SPANSthis returns the ordinal placeholder DuringRenderPurpose.TRANSLATEDthis returns new anchorRef for the AnchorRefTarget original was referring to- Parameters:
pageRef- url part without the anchor ref to resolve referenceanchorRef- anchor ref- Returns:
- anchorRef for the phase to be used for rendering
-
translatingSpan
Separate translation span. Will generate a paragraph of text which should be translated as one pieceDuring
RenderPurpose.TRANSLATION_SPANSthis adds the generated output to translation spans DuringRenderPurpose.TRANSLATED_SPANSoutput from renderer is suppressed, instead outputs corresponding translated span DuringRenderPurpose.TRANSLATEDcalls render -
nonTranslatingSpan
Separate non-translation span. Will generate a paragraph of text which will not be translatedDuring
RenderPurpose.TRANSLATION_SPANSthis adds the generated output to translation spans DuringRenderPurpose.TRANSLATED_SPANSoutput from renderer is suppressed, instead outputs corresponding translated span DuringRenderPurpose.TRANSLATEDcalls render -
translatingRefTargetSpan
void translatingRefTargetSpan(@Nullable @Nullable Node target, @NotNull @NotNull TranslatingSpanRender render) Separate translation span which is also a ref target- Parameters:
target- target node,render-
-
customPlaceholderFormat
void customPlaceholderFormat(@NotNull @NotNull TranslationPlaceholderGenerator generator, @NotNull @NotNull TranslatingSpanRender render) Temporarily change the format for placeholders- Parameters:
generator- placeholder generatorrender- render which will be used with the custom generator
-
getMergeContext
-