opencat/xliff
Composer 安装命令:
composer require opencat/xliff
包简介
XLIFF 1.2 writer and reader for the OpenCAT Framework
README 文档
README
XLIFF 1.2 writer and reader for the OpenCAT Framework.
Serialises a BilingualDocument to XLIFF 1.2 (plus a companion .skl skeleton file) and reads it back. XLIFF is the interchange format between the extraction/segmentation phase and the translation phase — it can be sent to a translator or a TMS and then read back to rebuild the translated file.
Installation
composer require opencat/xliff
Requires ext-dom and ext-libxml.
Writing XLIFF
use CatFramework\Xliff\XliffWriter; $writer = new XliffWriter(); $writer->write($doc, 'project.xlf'); // Also writes project.xlf.skl (JSON skeleton — required for rebuild)
Reading XLIFF
use CatFramework\Xliff\XliffReader; $reader = new XliffReader(); $doc = $reader->read('project.xlf'); // Loads the .skl file automatically (expects project.xlf.skl alongside) // Rebuild the original file format $filter->rebuild($doc, 'translated-output.docx');
XLIFF output format
<?xml version="1.0" encoding="UTF-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:catfw="urn:catframework"> <file original="report.docx" source-language="en-US" target-language="fr-FR" datatype="x-unknown"> <header> <skl><external-file href="project.xlf.skl"/></skl> </header> <body> <trans-unit id="seg-1" translate="yes"> <source>Hello <bpt id="1" rid="b1"><strong></bpt>world<ept id="2" rid="b1"></strong></ept>!</source> <target state="translated">Bonjour <bpt id="1" rid="b1"><strong></bpt>monde<ept id="2" rid="b1"></strong></ept>!</target> </trans-unit> </body> </file> </xliff>
Inline code mapping
InlineCode objects are serialised as XLIFF inline elements:
InlineCode |
isIsolated |
XLIFF element |
|---|---|---|
OPENING |
false | <bpt rid="…"> |
CLOSING |
false | <ept rid="…"> |
STANDALONE |
false | <ph rid="…"> |
OPENING |
true | <it pos="open" rid="…"> |
CLOSING |
true | <it pos="close" rid="…"> |
The catfw:equiv-text attribute carries InlineCode::$displayText when set, giving CAT tools a human-readable hint (e.g. <b> instead of the raw <strong> tag).
Segment status mapping
SegmentStatus |
XLIFF state |
|---|---|
Untranslated |
new |
Draft |
new |
Translated |
translated |
Reviewed |
signed-off |
Approved |
final |
Rejected |
needs-translation |
Locked segments (SegmentPair::$isLocked = true) are written with translate="no".
Skeleton file
The .skl file is a JSON-encoded copy of BilingualDocument::$skeleton — the filter-specific data needed to rebuild the original file. It is written alongside the XLIFF and must remain with it. The reader looks for {xliffPath}.skl automatically.
Related packages
opencat/core—BilingualDocument,SegmentPair,Segment,InlineCodeopencat/workflow— callsXliffWriteras the final step in the processing pipeline
opencat/xliff 适用场景与选型建议
opencat/xliff 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 opencat/xliff 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 opencat/xliff 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 45
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-09