Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Xliff Laravel Package

elasticms/xliff

XLIFF is a PHP library that generates and loads XLIFF files from associative arrays, supporting both regular text and HTML content through segmentation. It simplifies exchanging translatable content with translation tools and localization workflows.

View on GitHub
Deep Wiki
Context7

Reusable XLIFF import/export library (XLIFF 1.2 + 2.2) for EMS.

Frequently asked questions about Xliff
What is elasticms/xliff used for?
elasticms/xliff is a lightweight PHP library that generates and loads XLIFF translation interchange files from associative arrays. It supports both plain strings and HTML strings by segmenting the markup so translators can work with rich content. In a Laravel project it is typically used to export model or collection content for external translation tools and to import translated XLIFF files back into your database.
How do I install elasticms/xliff with Composer?
Install it with the command composer require elasticms/xliff, which pulls the package and its minimal XML-related dependencies. Because the library has no framework-specific dependencies, it can be used inside Laravel, Lumen, or any plain PHP application. After installation you can autoload its classes through Composer's PSR-4 autoloader without additional service provider registration.
Does elasticms/xliff support Laravel 10 and Laravel 11?
Yes. The package requires PHP 8.x and has minimal dependencies, which makes it compatible with the type system and dependency constraints of Laravel 10 and 11. It is framework-agnostic, so you can wrap it in a service class or a queued job rather than relying on a Laravel-specific integration. Always pin your PHP version (for example ^8.2) and run your test suite after upgrading Laravel.
How do I generate an XLIFF file from a PHP associative array?
You build an associative array where keys identify the translation units and values contain the plain text or HTML strings, then pass it to the library's generator to produce an XLIFF document. In Laravel, mapping Eloquent models or collections into that array structure keeps the integration simple and decoupled from your persistence layer. The generated file can then be written to storage or streamed to a translation platform such as Crowdin or Lokalise.
How do I load an XLIFF file back into an associative array?
The library's loader parses an XLIFF document and returns an associative array of translation units that you can iterate over. This makes it straightforward to update Laravel models or a dedicated translations table after receiving files back from translators. You should still validate the file against the expected XLIFF schema before importing to avoid malformed data reaching your database.
Does elasticms/xliff handle HTML content and segmentation?
Yes. The library segments HTML strings into translatable units so markup such as paragraphs, links, and inline tags is preserved during translation. This is useful for marketing pages, product descriptions, and documentation where rich text must remain intact. Complex or unusual markup, such as nested scripts or custom tags, should be tested and documented as a known limitation in your integration.
Which XLIFF versions does elasticms/xliff support?
The library supports both XLIFF 1.2 for legacy tooling and XLIFF 2.2 for modern translation platforms. Dual support reduces migration risk if you change translation vendors or upgrade your workflow later. Check that your target platform enforces specific 2.2 features like group or note elements before relying on them in your exports.
How do I handle large XLIFF files without memory issues in Laravel?
For exports or imports larger than a few megabytes, process data in chunks and dispatch the work to Laravel queue jobs instead of running it synchronously in a request. Benchmark DOM-based parsing against streaming approaches such as XMLReader if you expect very large files. Logging failures through Laravel Horizon or Sentry helps you catch memory or timeout problems early.
How can I test XLIFF export and import in a Laravel application?
Write feature tests that build a sample associative array, generate an XLIFF file, and assert the resulting XML contains the expected translation units and segments. Then load the file back and compare the parsed array with the original input to verify round-trip fidelity. Include fixtures with HTML content and both XLIFF 1.2 and 2.2 documents to cover the edge cases your application relies on.
Is elasticms/xliff actively maintained and are there alternatives?
The package is part of the elasticMS mono repository, so issues and pull requests are handled there rather than in a standalone repository. Community adoption is relatively small, so monitor releases and consider forking or vendoring the library if maintenance slows down. Alternatives include dedicated XLIFF tooling from translation vendors, but this library stands out for its simple associative-array API and built-in HTML segmentation.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console