Skip to content

Out of Range Error when exporting XLIFF 2.0 with empty or placeholder-only source tags #23

@The0Dev

Description

@The0Dev

Hello. I've run into a rather minor issue.

An "out of range" error occurs during export if an .xlf file contains source tags without readable text (e.g, empty or only with placeholders like ph).

Adding the attribute translate="no" to tags prevents the exception, but it would probably be better if it didn't happen even without the attribute.

Steps to Reproduce:

  1. Import the provided .xlf file (it's valid according to this)
  2. Attempt to export the file back to .xlf format.
  3. See the error

Expected Result:
The file exports successfully. Empty sources or placeholder-only sources are preserved.

The file:

<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.1" srcLang="en" trgLang="es">
    <file id="original_id">
        <unit id="unit_0">
            <segment>
                <source>Hello, World!</source>
            </segment>
        </unit>
        <!-- Triggers error: Source contains only a placeholder tag -->
        <unit id="unit_1">
            <segment>
                <source><ph id="0" disp="{Confirm_Button}" equiv="$BTN_CONF$" type="ui"/></source>
            </segment>
        </unit>
        <!-- Workaround: Empty source passes because translate="no" is set -->
        <unit id="unit_2" translate="no">
            <segment>
                <source></source>
            </segment>
        </unit>
        <!-- Triggers error: Empty source without translate="no" -->
        <unit id="unit_3">
            <segment>
                <source></source>
            </segment>
        </unit>
        <unit id="unit_4">
            <segment>
                <source>Normal translatable text.</source>
            </segment>
        </unit>
    </file>
</xliff>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions