XLF (XLIFF) 文件中的 ID 在 Symfony 中重要吗?

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

我想知道 trans-unit 标签上的 ID 在 XLF 文件中与 Symfony/PHP 一起使用时是否重要?它们在文件中应该是唯一的吗?跨文件?使用什么 string/integer 重要吗?我找不到关于它们的用途的文档,包括 Wikipedia.

这可能是一个更笼统的问题,但我目前正在使用 Symfony (PHP)。

对于 Symfony,它们并不重要。 Symfony 实际上并不真正支持 Xliff,它只知道如何从文件中提取 2 个元素并将其转换为键 -> 值数组,就像所有其他格式一样。

但是,如果您要使用翻译工具(您可能是,否则您选择了更简单的格式),那么您需要遵循 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.

如果我有所需的声誉,我会把它放在 Wouter J 的回答下的评论中,但由于情况并非如此,这里有另一个答案。

您选择的格式应该对您和您的译员都适用。如果您检查 https://en.wikipedia.org/wiki/Computer-assisted_translation#Some_notable_CAT_tools,您会发现许多翻译工具都内置了对 XLIFF 的支持,而 none 则支持 YAML。 另一方面,其中一些工具允许对输入文件进行基于正则表达式的解析,因此您可能应该与您的翻译人员讨论他更喜欢使用哪种格式:将一组正则表达式规则放在一起来处理 YAML 可能比他更适合不得不处理糟糕的 XLIFF(Wouter J link 的 XLIFF 示例有一些改进空间)。