CAT Tool File Filters: Preserve Tags and Structure

Learn how CAT tool file filters separate translatable text from markup, protect inline tags, and validate exported files without breaking the source.

Also in: UK RU EN
CAT Tool File Filters: Preserve Tags and Structure

A localization file can look perfectly readable in a text editor and still become unusable after translation: a placeholder moves, a closing tag disappears, or an attribute meant only for software gets sent to the linguist. CAT tool file filters prevent that kind of failure by deciding which content can change and which structure must survive.

A filter isn’t just an import switch. It’s a contract between the source file, the CAT environment, the person translating, and the software that will consume the exported file. That contract needs to say what counts as text, what counts as a tag, how each tag behaves, and how the final file will be checked.

What CAT tool file filters do

A CAT tool file filter converts a source file into content the translation environment can work with, then uses the translated content to rebuild an output file. The filter decides what a translator sees, what remains protected, and how markup maps back to the original structure.

Markup is the notation or structure around content. In XML, for example, elements mark sections of a document, while attributes add information to those elements. A visible sentence may sit inside several nested elements, and a short code in that sentence may stand for a link, variable, or formatting instruction.

A filter needs to keep those different parts distinct. Treating everything as plain text can expose code for editing; treating everything as uneditable markup can hide content that needs translation. Either mistake can produce a technically valid file with the wrong meaning, or a linguistically sound translation the target system can’t use.

The central distinction is between translatable content and structural content. Translatable content is language that should change for the target audience. Structural content controls where text belongs or how an application interprets it. Some data falls between the two: an attribute may contain a user-facing label, an identifier, or a value that must remain unchanged.

A useful filter therefore has two jobs:

  • Extraction: identify content to translate and represent protected material safely.
  • Reconstruction: place translated content back into the source format without losing required structure.

The second job matters as much as the first. A file that imports cleanly into a CAT tool can still fail on export if the writer changes encoding, drops comments, rearranges ordered content, or emits invalid tag nesting.

XLIFF 2.1, an interchange format for localization content, offers a useful model for inline codes. It distinguishes a standalone code from a code that starts or ends a span. The specification describes <ph> this way:

“Represents a standalone code of the original format.”

A standalone placeholder can represent a code such as a variable that appears at one point in a sentence. A formatting span, by contrast, has a start and an end. The distinction helps a filter preserve how markup behaves instead of flattening every code into an undifferentiated token.

XLIFF 2.1 uses <sc> and <ec> for the start and end of spanning codes. Each of these inline code elements has an identifier requirement, giving the CAT tool a way to associate related codes. The specification describes <sc> as:

“Start of a spanning original code.”

That separation is useful even when a project doesn’t use XLIFF as its source format. A custom filter can follow the same conceptual model: represent independent placeholders as standalone codes and paired formatting as a start/end pair. The export writer can then reconstruct the original file from a stable, explicit representation.

For a practical workflow, think about filters as a pipeline rather than a single configuration screen:

  1. Read and parse the source. Identify valid structure, encoding, and content boundaries.
  2. Apply extraction rules. Decide which element text or attributes are translatable.
  3. Represent protected structures. Create inline codes, locked content, or non-translatable metadata.
  4. Segment text. Split it into units for translation without breaking the logic of tags or placeholders.
  5. Validate the target. Check required codes and structural constraints.
  6. Write and test the output. Rebuild the file and confirm that the intended application can consume it.

Each stage can introduce a different failure. A parser may accept a file whose application-specific rules are wrong. A valid target segment may still omit a required placeholder. A structurally correct export may use whitespace or encoding the consuming system doesn’t expect. Testing the whole pipeline catches problems that an import preview can’t.

Filters sit within a larger translation setup. Teams building a repeatable process may also benefit from mapping remote-first translation agency tools and processes, especially when handoffs involve several file types and reviewers.

Decide what translators should see

A filter configuration starts with content inventory, not with a regular expression. List the elements, attributes, comments, and embedded text in representative files, then decide what each one means in the finished product.

For each content location, ask three questions:

  • Does a person see this value in the localized product?
  • Can the value be translated without changing how the software or document works?
  • Does the value need to stay attached to a particular tag, position, or neighboring code?

Those questions stop the common mistake of using a blanket rule such as “translate all text nodes” or “ignore every attribute.” A UI label inside an attribute may need translation. A name attribute may identify a code element and must not change. An XML comment may contain an instruction for developers, or a user-facing string inserted into the application. The filter needs a decision for each case.

A translation matrix makes those decisions visible:

Source location Typical question Possible filter treatment
Element text Is the text user-facing? Expose as a segment or protect as non-translatable
Attribute value Is the value content or metadata? Translate, lock, or include as tag metadata
Element name Does the name define structure? Preserve as markup
Comment Is the comment part of the localized experience? Exclude, or expose using a deliberate representation
Embedded placeholder Must software replace it at runtime? Preserve as an inline code and validate its presence

The word “typical” in the table matters. File formats don’t tell you whether every string is intended for translation. Project requirements, product behavior, and the source application’s conventions supply that context. When those conventions aren’t documented, confirm them with someone who can inspect the source system before writing extraction rules.

XML filters should use the authoritative schema when the project provides one. A DTD or XSD describes valid elements and attributes, which helps configure and verify the filter. A schema won’t tell you which valid strings are user-facing, but it will help separate permitted structure from accidental patterns in a sample file. Keep representative source files as well: schema knowledge and real examples solve different problems.

Attributes deserve their own review because a string can look readable without being a translation target. An id might identify an object; a title might be a visible label; a format value might control rendering. A filter that sends all three to translation risks damaging the source, while a filter that hides all attributes can leave genuine content untranslated.

Comments need an explicit rule too. Some projects use them only for developers, while others store text that should appear to a user. A CAT tool can represent unusual translatable content as tag metadata or an inline tag rather than treating the whole comment as ordinary prose. The choice should preserve both the comment’s identity and its intended translation behavior.

JSON makes the same issue visible in a different shape. RFC 8259 defines JSON as a text-based interchange format for structured data. Its data model includes strings, numbers, booleans, null, objects, and arrays. Translating the serialized file as a single text block ignores those types. A filter should select user-facing string values and leave keys, numbers, booleans, and other non-string values alone unless the project explicitly says otherwise.

JSON objects are unordered collections of name/value pairs, while arrays are ordered sequences. A writer shouldn’t rely on object-member order to preserve meaning, but it must preserve array order when order carries meaning. RFC 8259 states:

“An array is an ordered sequence of zero or more values.”

The translation filter’s reconstruction logic should therefore preserve array sequence and valid JSON syntax, while treating object-member order according to the format’s data model. A translator shouldn’t have to repair commas, quotes, escaping, or brackets after export.

Segmentation also affects what the translator sees. A phrase split across separate elements may become separate CAT segments, even if the interface displays it as one sentence. A filter that extracts metadata separately can help make labels editable without exposing structural code. Conversely, structural markup with no translatable content may be better represented as a single protected tag rather than several empty segments.

For example, consider a sentence that includes a runtime variable between two phrases. Extracting the variable as normal text lets it be edited or moved. Keeping it as a standalone inline code tells the CAT tool that the variable occupies a position but isn’t ordinary language. If a formatting tag surrounds a phrase, paired start and end codes preserve the span while allowing the text inside it to change.

The right extraction decision depends on how the original file uses that content, not on how convenient a sample looks in the editor. Check examples that include repeated values, empty elements, nested markup, comments, and strings with punctuation. A filter that works only for the cleanest sample is not ready for production.

For a broader view of how file structure and translation output interact, see how to preserve formatting when translating Word, PDF, and Excel documents. That guide focuses on document formatting, while CAT filters also need to protect machine-readable structure.

Preserve inline tags and placeholders

Inline tags are codes that appear inside a translatable segment. They can stand for formatting, links, variables, or pieces of source markup. Translators need enough freedom to produce natural target-language word order, but the file still needs the codes that make the sentence work.

A filter should distinguish at least three behaviors:

  • Standalone code: a placeholder or code that occurs at one point and doesn’t pair with another inline code.
  • Paired code: a start and end code that mark a span.
  • Structural tag: markup that organizes the file but isn’t part of the segment text.

The categories are about function, not appearance. A code that looks like <b> in a source file might be a formatting span, but a different element with similar-looking syntax could carry structural content. Parse the source format instead of inferring behavior from visual resemblance.

Paired codes need a matching relationship. If an opening code has an identifier and its closing code has a corresponding identifier, the filter should keep that relationship intact through translation and export. Target-language syntax may require a different word order, so the filter shouldn’t assume that codes must stay at precisely the same character position. Instead, it should check the constraints the format actually requires.

XLIFF 2.1 gives inline codes editing hints such as canCopy, canDelete, canReorder, and canOverlap. These attributes communicate how an inline code should be handled; they don’t make every target valid automatically. For example, an editing hint that permits deletion doesn’t remove the need to check whether the source application can render the resulting target. See the OASIS XLIFF 2.1 standard for the specification’s definitions.

That distinction matters when a CAT tool offers a tag as editable. “Editable” is a permission or hint, not a quality guarantee. A translator may be allowed to move a code but still need to keep a pair together, retain a required placeholder, or avoid nesting one span inside an invalid location. Write those constraints into validation rather than relying on visual familiarity.

A useful test case has a source segment containing a paired span and a standalone variable. Translate the words into a language where the variable belongs earlier in the sentence. Then verify that the target can move the variable and span where needed without changing their identity or breaking the pairing. The test shouldn’t only ask whether all tags remain; it should ask whether the target’s meaning and code structure remain valid.

Tag visibility is a design decision. Hiding a tag can reduce accidental edits, but the tool still needs to retain it in the target where required. Showing a tag can give translators control over placement, but it also creates a risk of deletion, duplication, or malformed nesting. Use protected or locked behavior for codes that shouldn’t be edited, and allow movement only where the format and linguistic context support it.

A required-placeholder rule is valuable when a code must appear in every target. A filter can flag a target that lacks a required tag rather than silently exporting it. A missing-code check alone doesn’t catch every problem: duplicated codes, mismatched pairs, invalid ordering, and a placeholder copied into the wrong sentence can still cause failures.

The validation model should capture rules at the correct level:

  • Presence: Does the target contain every required placeholder?
  • Identity: Does each target code map to a source code?
  • Pairing: Does each start code have its matching end code?
  • Nesting: Are paired codes nested in an order the format permits?
  • Multiplicity: Has a code been copied or repeated when duplication isn’t allowed?
  • Position and context: Does the code remain in a place the source application can interpret?

Not every project needs every rule for every code. A hyperlink placeholder and a formatting span have different behavior. The filter should document each code’s constraints so that a later configuration change doesn’t accidentally weaken validation.

Tag QA also belongs beside other automated translation checks. Automated QA checks for tags, numbers, terminology, and consistency can help teams think about tag integrity as one part of a larger target review, not as a substitute for checking meaning.

Choose parsers and regular expressions deliberately

A parser reads a structured format according to its syntax and exposes its elements, attributes, and relationships. Regular expressions match text patterns. The two approaches solve different problems, so the choice should depend on the structure the rule needs to understand.

Use a parser when extraction depends on nesting, element names, attributes, or the relationship between nodes. XML is hierarchical: an element can contain other elements, and the same element name can appear in different contexts. A parser can distinguish those contexts by examining the structure. A single pattern over raw text can’t reliably model all of those relationships.

Use regular expressions for stable, narrow patterns such as a specific placeholder convention or code-like string. Regex tagging can turn matched text into inline codes so translators don’t change it by mistake. That approach is useful when the underlying file has already been imported or when a separate filter has handled the document structure.

A regex rule isn’t a complete document importer. It doesn’t replace the parsing stage when the filter needs to understand a whole XML tree, validate element nesting, or rebuild a structured file. Treat regex as a focused extraction or post-processing stage, not as a general substitute for format-aware logic.

Overlapping regex rules need ordered tests. If one pattern matches text that another pattern also matches, changing rule order can change what becomes a tag. Review the rules as a set, not as isolated expressions. A preview of matched source strings and their resulting tags helps reveal cases where an early rule captures text that a later rule was meant to handle.

A practical approach looks like this:

  1. Start with the format parser. Read the source structure and identify the exact elements and attributes that matter.
  2. Define translatability rules. Specify which text nodes and attribute values should become segments.
  3. Apply narrow tagging rules. Use regular expressions only for well-defined inline patterns the parser doesn’t already handle.
  4. Review overlapping patterns. Test the ordered rules against real examples that include near-matches and edge cases.
  5. Check tag requirements. Mark critical placeholders as required and confirm that missing codes trigger a useful error.
  6. Run export tests. Rebuild translated files and verify both syntax and application behavior.

A regex test set should include positive examples, where a match is expected, and negative examples, where similar-looking text must remain ordinary content. Include cases with punctuation, adjacent codes, repeated placeholders, and variations that occur in real source files. A pattern that only matches the ideal example can silently miss the variation that causes a production defect.

Parser-based filters need tests too. The parser may correctly read valid XML while the extraction rules select the wrong nodes. It may also reject malformed input before the CAT tool can import it, which is useful only if the error message helps the person who needs to fix the file. Test both successful imports and controlled failures.

A useful boundary test is a file where the same attribute name appears on two different elements, one translatable and one structural. A context-free regex may match both. A parser-based rule can target the element and attribute combination that the project actually intends. If a regex is still used, constrain its scope and test against the full file rather than a cropped snippet.

Filter development should also separate parsing from writing. The parser determines what the source contains; the extraction layer decides what translators see; the writer reconstructs the output. Keeping those responsibilities clear makes it easier to test which stage caused a problem. A monolithic rule that mixes all three is harder to debug when a code disappears or a string lands in the wrong location.

Team workflows can add another layer of process around these technical decisions. The guide to building an MTPE workflow in an LSP covers broader handoffs and quality steps that sit around the file filter itself.

Validate exports, not just imports

An import preview tells you what the CAT tool extracted. It doesn’t prove that the exported file is valid, that the application can read it, or that the translated content appears in the intended place. Validation needs to follow a file all the way from source to target.

Start with structure. Parse the exported file and check for syntax errors, missing required elements, broken code pairs, and illegal nesting. If the output format has a schema, validate against it. A successful schema check is useful but doesn’t confirm that every project-specific rule is correct.

Next, check translation-specific constraints. Verify required placeholders, tag identity, and any rules about code movement or duplication. Compare source and target segment structures rather than assuming a target is valid because the editor accepted it. A CAT tool can help catch some tag errors, but custom rules still need their own tests.

Then review serialization choices. XML filters need explicit decisions about encoding, comments, and whitespace. An encoding declaration and the actual output encoding have to agree. Whitespace can carry meaning in some formats, so a setting that trims or collapses spaces shouldn’t be treated as harmless by default. Comment text might be ignored, preserved, or translated, but the writer shouldn’t drop it accidentally.

The same principle applies to JSON escaping and ordering. A writer should serialize valid strings correctly and preserve array order. Object-member order shouldn’t be used as a substitute for meaning. Translating a JSON file by editing raw serialized text risks changing syntax as well as content, so structured reading and writing are safer for format-aware workflows.

Make a regression set of files that reflects actual source variation. Include a small, readable file for debugging, but also keep examples with nested tags, comments, unusual whitespace, empty values, and multiple content types. A reference file can reveal what the filter encounters; the authoritative schema, when available, defines what the format permits.

A complete validation pass can follow this checklist:

  • Import: Did the filter open the source and identify the expected content?
  • Extraction: Did every intended string become translatable, with structural data protected?
  • Tags: Did every required placeholder survive, and did paired codes remain valid?
  • Segmentation: Did meaningful phrases stay together, and did metadata avoid accidental merging with prose?
  • Whitespace: Did meaningful spaces survive around elements and inline codes?
  • Encoding: Does the output declaration match the bytes written by the exporter?
  • Serialization: Does the output parse as the expected format?
  • Application check: Can the target product or workflow open and display the localized file?
  • Regression: Do earlier sample files still import and export correctly after a rule change?

For an XML filter, run an export cycle using source files that exercise the schema and the team’s own conventions. For a JSON filter, read and write structured values, then compare the parsed source and target structures. For regex tagging, inspect the preview and verify both matches and non-matches before applying rules to a production file.

Common failures often arise from a correct rule applied at the wrong scope. A placeholder pattern can match a code inside documentation where the text should remain translatable. A whitespace setting can remove a separator that an application uses to render neighboring elements. A writer can emit valid XML but omit a comment that a downstream build step expects. The fix is not always a more complex pattern; sometimes the filter needs a better content map or an explicit exception.

When teams compare CAT environments, filter behavior belongs alongside translation memory, terminology, and project management. A tool comparison such as memoQ vs Trados Studio for freelancers can frame the wider choice, but a custom filter still needs testing against the team’s own files and rules.

When custom filter development is worth it

A custom filter makes sense when recurring files have rules that a general filter can’t express clearly, or when import and export errors create repeated cleanup work. Stable structure, documented content rules, and representative files make a project easier to configure and maintain.

A custom filter isn’t always the right first move. If a standard format filter already handles the source and the remaining issue is a small set of predictable placeholders, a narrow tagging stage may be enough. If the source changes constantly and nobody owns the schema or examples, custom code can create a new maintenance problem rather than solve the old one.

Consider the trade-offs before starting:

Situation Likely approach Main risk to check
Standard XML with a known schema Configure a schema-aware filter Confirm which valid fields are actually translatable
A few stable code-like strings in existing content Add a focused tagging stage Test rule overlap and missing matches
Deeply nested content with context-dependent rules Use a parser-based custom filter Keep parser, extraction rules, and writer separately testable
Unclear source conventions and no representative files Clarify the format contract first A filter can’t infer intended translation behavior safely

A small proof of concept should cover one representative source file, one deliberately difficult example, and a full export test. The team should be able to explain why each content location is translatable or protected. If that decision can’t be made, the unresolved issue is a content specification problem, not a filter implementation problem.

Document the filter’s assumptions alongside its rules: expected schema, translatable nodes, protected attributes, placeholder behavior, whitespace policy, encoding, and failure messages. Keep sample inputs and expected outputs with that documentation. Clear assumptions let future maintainers tell the difference between an intentional rule and an accidental side effect.

A maintained filter also needs ownership. Someone should review changes to source formats, update tests when new elements appear, and check that exported files still work in the destination system. Without that responsibility, a once-correct filter can become unreliable as a project adds fields or changes how placeholders are used.

Teams can use an introduction to OmegaT for beginner translators to understand how a CAT environment presents tags to translators. The interface matters, but the filter’s deeper job remains the same: expose language, protect structure, and make the output testable.

One final design rule keeps the work manageable: make each decision explicit. A tag should have a known role. A translatable value should have a known location. A required placeholder should have a validation rule. An output file should have a test that checks more than whether it exists. Those decisions turn an opaque import configuration into a filter the team can reason about.

FAQ

How do CAT tool file filters preserve inline tags during translation?

CAT tool filters represent formatting and placeholders as structured inline codes rather than ordinary text. Paired codes mark a span, while a standalone code represents an independent placeholder; export logic maps those codes back into the source structure.

How do I decide which XML elements and attributes should be translatable?

Set rules for element text, attributes, comments, and structural tags separately. Use the authoritative DTD or XSD when available, and test the rules against representative files because a schema describes valid structure but doesn’t identify every user-facing string.

How can I prevent placeholders and code from changing in a CAT tool?

Represent critical placeholders as protected inline codes and validate that required codes remain in the target. Regular-expression tagging can handle stable code-like patterns, but the rules need tests for both intended matches and similar-looking text that should remain editable.

Should I use a parser or regular expressions for a CAT filter?

Use a parser when rules depend on hierarchy, nesting, or context. Use regular expressions for narrow, stable text patterns or as a tagging step after a format-aware filter has imported the document.

How should a custom CAT filter validate tag pairs and regenerated files?

Check that paired codes have matching identities and valid nesting, and that critical standalone placeholders remain present. Then export the file, parse it, verify encoding and whitespace, and test whether the target application can consume it.

Try ChatsControl

AI platform for professional translators

Try for free →