4

In Symfony 2's documentation regarding translations all of the XLIFF examples appear to use file.ext as the original file attribute. From XLIFF 1.2's documentation:

Original file - The original attribute specifies the name of the original file from which the contents of a element has been extracted.

In Symfony 2's case I don't belief we're actually extracting any contents for translation, but the original attribute is required. The usage of file.ext is never explained in Symfony 2's documentation, whether it is simply a place holder and ignored, or whether it needs to point to an actual file. My best guess is that it is ignored by Symfony 2, but I haven't had a chance to do any tests or dig around in the code.

Second question: Would it be appropriate to specify a default set of translations, e.g. messages.default.yml and use this as the original file from which the XLIFF translations are derived?

XLIFF seems a little bit like overkill when it comes to translations for use with web applications...

Sean Quinn
  • 2,131
  • 1
  • 18
  • 48
  • For your second question I guess it is ok to create `messages.default.yml` but I don't see the point. You can specify the default locale in `parameters.ini` and that should be your file from which the translations are derived. – cheesemacfly Feb 25 '13 at 16:51
  • Fair enough, yes, I can (and _should_) specify the default locale in the application's configuration. – Sean Quinn Feb 25 '13 at 16:58
  • I have no idea what Symphony 2 is, but the question is still a good one (nearly 10 years later). If there is no "source" file as such, why is the "original" attribute mandatory, and what should we put in it. – Greg Woods Dec 09 '22 at 09:34

1 Answers1

5

Although original attribute of <file> is required in Xliff 1.2 spec and schema, you can ignore it and have a dummy string as its value so that your file passes schema validation.

One of the common uses of this property is when the strings from multiple documents (.properties files, gettext files, etc.) are extracted and reformatted as Xliff trans-units so that the strings from each individual file are placed under a respective individual <file> tag. original attribute can be used to keep the original filenames in an Xliff file with multiple <file> tags:

<?xml version="1.0" encoding="utf-8" ?>
<xliff version="1.1" xml:lang='en'>
 <file source-language='en' target-language='de' datatype="plaintext" original="Sample.po">
  ...
   <body>
    <trans-unit id="1" restype="button" resname="IDC_TITLE">
     <source>Title</source>
    </trans-unit>
    <trans-unit id="2" restype="label" resname="IDC_STATIC">
     <source>&amp;Path:</source>
    </trans-unit>
  ...
 </file>
 <file source-language='en' target-language='de' datatype="plaintext" original="Sample.properties">
    <trans-unit id="1" restype="label" resname="IDC_LABEL">
  ...
   </body>
 </file>
</xliff>

I agree that using Xliff for localizing small web applications can often be a bit of an overkill, but this format is arguably the only industry standard file format for localization data interchange at the moment. This makes it very popular with large scale localization implementation either simple source/target-structured files or heavily customized and tailored ones like those used in Translation Management Systems like SDL Idiom Worldserver.

Additionally, there is compatibility between Xliff and other standard file formats of OAXAL family.

Shervin
  • 1,936
  • 17
  • 27
  • 1
    Thanks for the informative response! I've sort of avoided the topic of localization during development, in part because I want to use Xfliff but its also very intimidating. Good to know that the `original` file attribute is, more or less, arbitrary. – Sean Quinn Apr 12 '13 at 13:32
  • 1
    Anytime. And you are right. Don't pay much attention to the spec except for the basics. It's just full of rarely used features. All in all, simplified Xliff can streamline scalable localization efforts. The commonly used features are discussed [here](http://www.opentag.com/xliff.htm). – Shervin Apr 12 '13 at 16:09