Search code examples
phpsymfonyxliff

Are the IDs in XLF (XLIFF) files important in Symfony?


I'm wondering if the IDs on trans-unit tags are important in XLF files when using them with Symfony/PHP? Should they have be unique within a file? Across files? Does it matter what string/integer is used? I can't find documentation of what, if anything they're used for, including on Wikipedia.

It's probably a more generic question, but I'm working with Symfony (PHP) at the moment.


Solution

  • For Symfony, they don't matter. Symfony doesn't actually really support Xliff, it just knows how to extract 2 elements from the file and transform it into a key -> value array, as with all other formats.

    However, if you're going to use translation tools (you probably are, otherwise you had choosen a simpler format), then you need to follow the Xliff specification:

    The required id attribute is used to uniquely identify the <trans-unit> within all <trans-unit> and <bin-unit> elements within the same <file>.

    ... (from id specs):

    [...] The value of the id element is determined by the tool creating the XLIFF document. [...]

    Value description: Text. Note that, while allowed, spaces are usually not used in identifiers.