Interface TranslationContext
-
- All Known Subinterfaces:
NodeFormatterContext
,TranslationHandler
,TranslationHandlerFactory
- All Known Implementing Classes:
NodeFormatterSubContext
,TranslationHandlerImpl
public interface TranslationContext
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
customPlaceholderFormat(TranslationPlaceholderGenerator generator, TranslatingSpanRender render)
Temporarily change the format for placeholdersHtmlIdGenerator
getIdGenerator()
MergeContext
getMergeContext()
RenderPurpose
getRenderPurpose()
Get the reason this format rendering is being performedMutableDataHolder
getTranslationStore()
Get MutableDataHolder for storing this translation run values across render purpose phasesboolean
isPostProcessingNonTranslating()
boolean
isTransformingText()
Returns false if special translation functions are no-opsvoid
nonTranslatingSpan(TranslatingSpanRender render)
Separate non-translation span.void
postProcessNonTranslating(java.util.function.Function<java.lang.String,java.lang.CharSequence> postProcessor, java.lang.Runnable scope)
<T> T
postProcessNonTranslating(java.util.function.Function<java.lang.String,java.lang.CharSequence> postProcessor, java.util.function.Supplier<T> scope)
java.lang.CharSequence
transformAnchorRef(java.lang.CharSequence pageRef, java.lang.CharSequence anchorRef)
DuringRenderPurpose.TRANSLATION_SPANS
this converts anchorRef to ordinal placeholder id DuringRenderPurpose.TRANSLATED_SPANS
this returns the ordinal placeholder DuringRenderPurpose.TRANSLATED
this returns new anchorRef for the AnchorRefTarget original was referring tojava.lang.CharSequence
transformNonTranslating(java.lang.CharSequence prefix, java.lang.CharSequence nonTranslatingText, java.lang.CharSequence suffix, java.lang.CharSequence suffix2)
Transform non-translating textjava.lang.CharSequence
transformTranslating(java.lang.CharSequence prefix, java.lang.CharSequence translatingText, java.lang.CharSequence suffix, java.lang.CharSequence suffix2)
Transform translating text but which is contextually isolated from the text block in which it is located ie.void
translatingRefTargetSpan(Node target, TranslatingSpanRender render)
Separate translation span which is also a ref targetvoid
translatingSpan(TranslatingSpanRender render)
Separate translation span.
-
-
-
Method Detail
-
getIdGenerator
@Nullable HtmlIdGenerator getIdGenerator()
-
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
-
isTransformingText
boolean isTransformingText()
Returns false if special translation functions are no-opsDuring
RenderPurpose.TRANSLATION_SPANS
this is true DuringRenderPurpose.TRANSLATED_SPANS
this is true DuringRenderPurpose.TRANSLATED
this is true- Returns:
- true if need to call translation related functions
-
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 textDuring
RenderPurpose.TRANSLATION_SPANS
this converts text to non-translating placeholder based on ordinal id DuringRenderPurpose.TRANSLATED_SPANS
this returns the non-translating placeholder based on ordinal id DuringRenderPurpose.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 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 java.util.function.Function<java.lang.String,java.lang.CharSequence> postProcessor, @NotNull java.lang.Runnable scope)
- Parameters:
postProcessor
- id post processor for TRANSLATED purposescope
- 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 purposescope
- 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 referenceDuring
RenderPurpose.TRANSLATION_SPANS
this converts text to non-translating placeholder based on ordinal id and adds it to translation snippets DuringRenderPurpose.TRANSLATED_SPANS
this returns the non-translating placeholder based on ordinal id DuringRenderPurpose.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 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 java.lang.CharSequence transformAnchorRef(@NotNull java.lang.CharSequence pageRef, @NotNull java.lang.CharSequence anchorRef)
DuringRenderPurpose.TRANSLATION_SPANS
this converts anchorRef to ordinal placeholder id DuringRenderPurpose.TRANSLATED_SPANS
this returns the ordinal placeholder DuringRenderPurpose.TRANSLATED
this 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
void translatingSpan(@NotNull TranslatingSpanRender render)
Separate translation span. Will generate a paragraph of text which should be translated as one pieceDuring
RenderPurpose.TRANSLATION_SPANS
this adds the generated output to translation spans DuringRenderPurpose.TRANSLATED_SPANS
output from renderer is suppressed, instead outputs corresponding translated span DuringRenderPurpose.TRANSLATED
calls render
-
nonTranslatingSpan
void nonTranslatingSpan(@NotNull TranslatingSpanRender render)
Separate non-translation span. Will generate a paragraph of text which will not be translatedDuring
RenderPurpose.TRANSLATION_SPANS
this adds the generated output to translation spans DuringRenderPurpose.TRANSLATED_SPANS
output from renderer is suppressed, instead outputs corresponding translated span DuringRenderPurpose.TRANSLATED
calls render
-
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 generatorrender
- render which will be used with the custom generator
-
getMergeContext
@Nullable MergeContext getMergeContext()
-
-