Weave Code
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

View on GitHub
Deep Wiki
Context7

[READONLY] Library to create and load XLIFF files with associative arrays containing simple strings or HTML strings

Frequently asked questions about Xliff
How do I integrate elasticms/xliff into a Laravel project for handling translations?
Install via Composer with `composer require elasticms/xliff`, then use its associative-array API to export Eloquent models to XLIFF files. For example, pass a collection of `Post` models to the `export()` method, specifying locales and HTML segmentation. The package works standalone or alongside Laravel’s built-in localization features.
Does this package support Laravel 11 and PHP 8.2+?
Yes, elasticms/xliff is fully compatible with Laravel 10/11 and PHP 8.2+. The package leverages PHP’s core XML libraries (SimpleXML/DOMDocument) and avoids framework-specific dependencies, ensuring smooth integration. Always pin your PHP version in `composer.json` to avoid compatibility drift.
Can I use this to export HTML content with proper segmentation for translators?
Absolutely. The package segments HTML content into translatable chunks while preserving markup, making it ideal for rich-text fields like product descriptions or CMS pages. Test with complex HTML (e.g., tables, nested divs) to ensure segmentation meets your needs, as edge cases may require custom logic.
How do I handle large XLIFF files (e.g., 20MB+) without memory issues?
For large files, use Laravel’s queue system to process exports in chunks. The package supports streaming via XMLReader, but benchmark performance first. Alternatively, split exports by locale or model type to reduce memory overhead during processing.
Will this work with translation platforms like Crowdin or Lokalise?
Yes, elasticms/xliff supports both XLIFF 1.2 and 2.2, ensuring compatibility with most translation tools. Verify your platform’s requirements (e.g., XLIFF 2.2’s `<group>` tags) and adjust your export configuration accordingly. Webhooks or polling can sync translations back to Laravel.
How do I validate XLIFF files before importing them into Laravel?
Use Laravel’s validation rules or middleware to check XLIFF files against XLIFF 1.2/2.2 schemas before import. The package doesn’t include built-in validation, so implement custom logic to reject malformed files early. Log validation errors via Laravel’s logging or Sentry for debugging.
Can I store translations in a separate table instead of JSON columns?
Yes, the package’s associative-array API works with any data structure, including separate `model_translations` tables. Design your database schema to match your workflow (e.g., one-to-many relationships for translations) and map Laravel models to the package’s expected format during export/import.
What’s the best way to automate XLIFF exports for translators?
Trigger exports via Laravel Artisan commands (e.g., `php artisan xliff:export`) or webhooks from your translation platform. For dynamic content, use model observers or Laravel events to auto-generate XLIFF files when models are updated. Queue jobs for reliability.
Are there alternatives to elasticms/xliff for Laravel XLIFF support?
Alternatives include `spatie/laravel-translatable` (for JSON-based translations) or `mtdowling/jms-serializer` (for custom XLIFF handling). However, elasticms/xliff stands out for its focus on XLIFF 1.2/2.2, HTML segmentation, and Laravel integration. Compare features like schema validation and performance for your use case.
How do I handle locale fallbacks (e.g., en → es → default) with this package?
Configure fallbacks in your Laravel localization settings (e.g., `App::setLocale()` or `config/app.php`). When exporting to XLIFF, include fallback locales in the metadata or use the package’s associative-array API to map translations hierarchically. Import logic should respect these fallbacks during database updates.
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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views