Context
I’m developing a custom MT translation provider plug-in for Trados Studio 2024 (Studio18).
The provider implements ITranslationProvider
and ITranslationProviderLanguageDirection
, and returns SearchResults
from SearchSegment
.
Environment
• Trados Studio: 18.0.1.2259 (Studio18)
• Sdl.Core.PluginFramework.Build: 18.0.1
• .NET Framework: 4.8
• OS: Windows 10 Enterprise
• Language pair: ja-JP → en-US
Goal
I want to build a context-aware MT provider that uses surrounding segments (previous/next) to improve translation quality during interactive editing in the Studio editor.
Observations
• When the first segment becomes active in the editor, SearchSegment is called multiple times (4+), even without navigating to another segment.
• The API does not expose which segment is currently active, nor does it allow querying adjacent segments from within SearchSegment.
• I also observe parallel calls on different threads, and calls for the next segment (likely prefetch), which I assume are part of editor optimizations.
Minimal code surface
• SearchSegment signature I use: public SearchResults SearchSegment(SearchSettings settings, Segment segment)
• I log each invocation with a correlation id and thread id. Example excerpt: [DEBUG] SearchSegment start. mode=NormalSearch, sourceText(len)=29 [DEBUG] SearchSegment start. mode=NormalSearch, sourceText(len)=36
• GetLanguageDirection is also called repeatedly; I cache the language direction instance on my side.
What I expected
• Either a way to:
• Know which segment is currently active in the editor (e.g., an index/id or context object), and/or
• Retrieve adjacent segments (previous/next) from within SearchSegment for better context handling,
• Or official guidance on the intended pattern to access reliable context for interactive MT in the editor.
What I tried already
• Implemented only SearchSegment for interactive use (SearchSegments is used in batch; I can see order there).
• Confirmed SupportsTranslation = true; removed all NotImplementedException from the pipeline methods.
• Added logging; observed that SearchSegment is invoked multiple times for what appears to be the active segment and also for its neighbor (prefetch).
• Considered heuristics (thread-local last query cache), but they are not reliable because of prefetch and parallel execution.
Questions
1. Is it expected that SearchSegment is called multiple times for a single active segment and also for neighboring segments (prefetch) in the editor?
2. Is there any supported API to:
• Identify which segment is currently active in the editor from within SearchSegment?
• Retrieve previous/next segment text (or broader paragraph context) during interactive translation?
3. If direct editor context is not available by design, what are the recommended best practices for building a context-aware MT provider in Studio (e.g., leveraging structure context, different interfaces, or another extension point)?
4. Are there sample providers or documentation that demonstrate accessing reliable context during interactive editing?
Thanks in advance for any pointers or references to official docs/samples.