- What is jobmetric/laravel-translation used for?
- It is a Laravel package for managing multilingual translations that are stored in the database rather than only in flat language files. It ships Eloquent models, factories, migrations, validation requests and rules, and events, plus the HasTranslation and HasDynamicTranslation traits for attaching translations to your own models. Typical use cases are admin-editable language strings, per-entity translations, and dynamic translation lookups at runtime.
- How do I install jobmetric/laravel-translation in a Laravel application?
- Install it with Composer, then wire up the package service provider according to the repository instructions, publish any config or migration assets, and run php artisan migrate. Note that version 3 moves files under a panelify/translation namespace, so confirm the correct autoload path and namespace after install. Always check the composer.json of the tagged release you install for the exact package name and constraints.
- Which Laravel and PHP versions does this package support?
- The provided documentation does not list explicit version constraints, so verify them in the package composer.json before adopting it. Check the require and require-dev blocks for the Laravel framework and PHP version ranges, and confirm they match your application's constraints. If you are on an older Laravel release, test on a branch before upgrading.
- What is the difference between HasTranslation and HasDynamicTranslation?
- HasTranslation is the standard trait for models whose translations are stored in related translation records. HasDynamicTranslation handles runtime resolution of translation values, which is useful when keys or locales are not known at build time. Version 3 changes the HasDynamicTranslation behavior, so audit any overrides or custom implementations before upgrading.
- How do I upgrade from version 2.x to 3.x?
- Create an upgrade branch, update the Composer constraint, and resolve the namespace and autoload changes introduced by the move to panelify/translation. Run the migrations in staging first, then search your codebase for removed or renamed classes such as TranslationContract and the old request classes. Refactor those usages, re-run your application and package test suites, and deploy with a rollback plan plus a post-deploy translation integrity check.
- Why was TranslationContract removed in version 3 and what should I use instead?
- The contract was removed as part of the v3 redesign, which is a breaking change for any code that type-hints or extends it. The documentation reviewed here does not name an official replacement, so check the changelog and source for the concrete model or interface now used. In the meantime, depend on the Eloquent translation model or your own abstraction rather than the removed contract.
- Do the version 3 migrations change or destroy existing translation data?
- Version 3 alters the migrations, and the available assessment does not confirm whether the changes are purely additive or destructive. Back up your translation tables, run the migrations on a copy of production data in staging, and compare schemas and row counts before and after. Also review newly introduced indexes, since database-backed translations depend on proper indexing for query performance.
- Why did the package files move to the panelify/translation namespace?
- The v3 release relocates the package under panelify/translation, which changes namespaces, file paths, and potentially autoload mappings. Existing imports, service provider registrations, and published assets that reference the old namespace will fail until updated. Treat the new namespace as the target for future releases, but confirm with the maintainers that it is stable.
- Is this package suitable for production with a large number of translations?
- Yes, with care: database-backed translations mean every lookup can hit the database, so avoid repeated dynamic translation calls in hot paths. Add caching for frequently requested keys, review indexes on the translation tables, and consider eager loading when translating collections of models. Also plan monitoring for missing translation keys and migration failures.
- How do I test translations and what should I verify before release?
- The v3 release adds substantial test coverage, but you should still write your own feature tests that assert translated output per locale. Run the migrations in a lower environment, verify validation rules and request classes behave as expected, and assert that event listeners still fire after the trait changes. If you need alternatives, compare with spatie/laravel-translation-loader or built-in Laravel JSON translation files before committing to a database-backed approach.