East Translation
Extension to provide translations in #East applications or website to manage easily translatable objects.
Package, to use with East Common, to translate easily yours persisted business objects in multiples languages, without manage translations, for each object.
This package is also built on MongoDb (and Doctrine ODM) to persist all contents into a MongoDB database, but it can be configured to use other system. The translating behavior come from the Doctrine Extension Gedmo, but the translation extension has been fully reworking and rewrited and included to this package (Gedmo is not required).
This package is framework free, and can be easily integrated with any framework.
A default integration to Doctrine is available.
This website is built on this package with Doctrine ODM 2.9.
Features
MongoDb
All translations are stored into a MongoDb.
Dotrine
Usable with Doctrine ODM and ORM.
PSR-11
Interoperable with any framework implementing the PSR-11 recommendation.
Fork the project on GitHub
It is open source! Hosted, developed, and maintained on GitHub.
View GitHub Project
Support this project on Patreon
This project is free and will remain free, but its development is not. If you like it and help us maintain it and evolve it, don't hesitate to support us on Patreon.
Support it
Example
<?php
//// Configuration
//These operations are not reauired with teknoo/east-translation-symfony
//config/packages/east_translation_di.yaml:
di_bridge:
definitions:
- '%kernel.project_dir%/vendor/teknoo/east-translation/infrastructures/doctrine/di.php'
//In doctrine config (east_translation_doctrine_mongodb.yaml)
doctrine_mongodb:
document_managers:
default:
auto_mapping: true
mappings:
TeknooEastTranslationDoctrine:
type: 'xml'
dir: '%kernel.project_dir%/vendor/teknoo/east-translation/infrastructures/doctrine/config/doctrine'
is_bundle: false
prefix: 'Teknoo\East\Translation\Doctrine\Object'
//// PHP Class
namespace Acme;
class Article implements TranslatableInterface
{
private string $localeField = '';
public function __construct(
public readonly string $id,
public string $name,
public string $content
) {
}
public function getId(): string
{
return $this->id;
}
public function getLocaleField(): ?string
{
return $this->localeField;
}
public function setLocaleField(?string $localeField): TranslatableInterface
{
$this->localeField = $localeField;
return $this;
}
}
//// Doctrine configuration
<?xml version="1.0" encoding="UTF-8"?>
<!--Article.mongodb.yml-->
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<document name="Acme\Article" collection="contents" inheritance-type="COLLECTION_PER_CLASS">
<id type="string" strategy="UUID"/>
<field field-name="name" type="string" nullable="false"/>
<field field-name="content" type="string" />
</document>
</doctrine-mongo-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!--Article.mongodb.translate.yml-->
<east-translation xmlns="http://xml.teknoo.it/schemas/doctrine/east-translation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xml.teknoo.it/schemas/doctrine/east-translation
http://xml.teknoo.it/schemas/doctrine/east-translation.xsd">
<object name="Acme\Article">
<field field-name="title" fallback="true"/>
<field field-name="content"/>
</object>
</east-translation>