Download the PHP package tmi/translation-bundle without Composer

On this page you can find all versions of the php package tmi/translation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package translation-bundle

TMI Translation Bundle - Doctrine Entity Translations for Symfony

CI codecov PHPStan Type Coverage Latest Version License PHP 8.4+ Symfony 7.3+ Doctrine ORM 3.5+ Total Downloads GitHub Stars Maintained

A modern, high-performance translation bundle for Symfony that stores entity translations in the same table as the source entity - no expensive joins, no complex relations.

๐Ÿš€ Why This Bundle?

This bundle solves: Symfony Doctrine translation, entity localization, multilingual entities, Doctrine translatable, Symfony translation bundle, database translations, entity translations

โŒ Traditional Translation Problems:

โœ… Our Solution:

๐ŸŽฏ Key Features

๐Ÿ—๏ธ About This Version

This is a complete refactoring based on PHP 8.4, Symfony 7.3, and Doctrine ORM 3.5 of the fork from umanit/translation-bundle, implemented with modern development practices and featuring 100% code coverage with comprehensive test suites.

โš ๏ธ Limitations

๐Ÿ“ฆ Installation

Register the bundle to your config/bundles.php.

โš™๏ธ Configuration

Configure your available locales in framework.yaml and, optionally, additional bundle settings:

Doctrine DBAL Custom Type - TuuidType

To use the TuuidType in your Symfony project, you must register it in your Doctrine configuration:

This ensures that Doctrine recognizes the tuuid type and avoids errors like:

๐Ÿš€ Quick Start

Make your entity translatable

Implement Tmi\TranslationBundle\Doctrine\TranslatableInterface and use the trait Tmi\TranslationBundle\Doctrine\ModelTranslatableTraiton an entity you want to make translatable.

Translate your entity

Use the service tmi_translation.translator.entity_translator to translate a source entity to a target language.

Every attribute of the source entity will be cloned into a new entity, unless specified otherwise with the EmptyOnTranslate attribute. Generated IDs (properties with #[ORM\Id] + #[ORM\GeneratedValue]) are automatically reset to null on cloned translations.

๐Ÿ”ง Advanced Usage

Usually, you don't wan't to get all fields of your entity to be cloned. Some should be shared throughout all translations, others should be emptied in a new translation. Two special attributes are provided in order to solve this.

SharedAmongstTranslations

Using this attribute will make the value of your field identical throughout all translations: if you update this field in any translation, all the others will be synchronized. If the attribute is a relation to a translatable entity, it will associate the correct translation to each language.

Note: ManyToMany associations are not supported with SharedAmongstTranslations yet.

โš ๏ธ Ordering caveat. Shared values propagate to translations created after the value is set. If you set a shared field in one locale and translate the entity to other locales later, those earlier siblings keep their stale value. To back-fill existing data, run:

The command propagates #[SharedAmongstTranslations] column values from the default-locale row to every sibling. Shared associations are out of scope (and unsupported).

EmptyOnTranslate

This attribute will empty the field when creating a new translation. ATTENTION: The field has to be nullable or instance of Doctrine\Common\Collections\Collection!

Translate event

You can alter the entities to translate or translated, before and after translation using the Tmi\TranslationBundle\Event\TranslateEvent

Filtering your contents

To fetch your contents out of your database in the current locale, you'd usually do something like $repository->findByLocale($request->getLocale()).

Alternatively, you can use the provided filter that will automatically filter any Translatable entity by the current locale, every time you query the ORM. This way, you can simply do $repository->findAll() instead of the previous example.

Add this to your config.yml file:

(Optional) Disable the filter for a specific firewall

Usually you'll need to administrate your contents. For doing so, you can disable the filter by configuring the disabled_firewalls option in your configuration:

Quick Fix for unique fields

If you need a translatable slug (or UUID), adjust your database schema to make the slug unique per locale, instead of globally:

Querying Locale Variants

Always use these helpers for cross-locale lookups. Hand-rolled WHERE tuuid = ... queries get the tmi_translation_locale_filter wrong and silently return only the current-locale row.

The quickest way is to extend the ready-made TranslatableEntityRepository base class:

If your repository must extend something else, use TranslatableRepositoryTrait directly (v2.1):

Both methods temporarily disable the tmi_translation_locale_filter (if enabled) to query across all locales.

The tuuid column is automatically indexed: the bundle injects a composite (tuuid, locale) index into every translatable entity at mapping time, so locale-variant lookups never hit an unindexed scan. Set unique_locale_variants: true to promote it to a UNIQUE constraint โ€” do this only once existing data is free of duplicate locale rows (see tmi:translation:doctor).

Translation Linkage & Diagnostics

Every locale variant of an entity shares one Tuuid. Translations created through EntityTranslator::translate() inherit it automatically. If application code instead does new Entity() + setLocale('de_DE') and persists it without a shared Tuuid, the result is a standalone entity linked to no other locale โ€” a silent data bug.

The bundle guards against this:

๐Ÿ“Š Performance Comparison

Operation Traditional Bundles TMI Translation Bundle
Fetch translated entity 3-5 SQL queries 1 SQL query
Schema complexity Multiple tables Single table
Join operations Required None
Cache efficiency Low High

๐Ÿค– AI-Assisted Development

This bundle includes AI skills that help you implement translations correctly. These skills work with Claude Code and other AI coding assistants.

Available Skills

Skill Purpose When to Use
Entity Translation Setup Guides you through making any Doctrine entity translatable "Make my Product entity translatable"
Translation Debugger Diagnoses and fixes translation configuration issues "Translation not working", "Why isn't my entity translating?"
Custom Handler Creator Helps create custom handlers for specialized field types "Create a handler for encrypted fields"

Using with Claude Code

If you're using Claude Code, the skills are automatically available when working in this project. Simply describe what you need:

Claude Code will automatically invoke the appropriate skill and guide you through the process.

Using with Other AI Assistants

The skills are defined in .agents/skills/ and follow a standard markdown format. Point your AI assistant to:

For comprehensive documentation optimized for AI assistants, see:

๐Ÿ“– Upgrading

See UPGRADING.md for migration guides between major versions.

๐Ÿค Contributing

We welcome contributions!

๐Ÿ“„ License

This bundle is licensed under the MIT License.

๐Ÿ™ Acknowledgments

Based on the original work by umanit/translation-bundle, now completely modernized for current PHP and Symfony ecosystems.


โญ If this bundle helps you, please give it a star on GitHub!


All versions of translation-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
doctrine/doctrine-bundle Version ^2.18 || ^3.0
doctrine/orm Version ^3.5.7
symfony/console Version ^8.0
symfony/framework-bundle Version ^8.0
symfony/security-bundle Version ^8.0
symfony/yaml Version ^8.0
symfony/property-access Version ^8.0
twig/twig Version ^3.22.0
symfony/translation-contracts Version ^3.6.1
ext-json Version *
ext-mbstring Version *
symfony/uid Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tmi/translation-bundle contains the following files

Loading the files please wait ...