wandi/i18n-bundle

WandiI18nBundle

Installs: 70

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 5

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.2 2020-12-21 17:17 UTC

This package is auto-updated.

Last update: 2024-04-22 00:39:52 UTC


README

Wandi/I18nBundle is a Symfony bundle used to assist internationalization of projects.

Setup

Install via composer

$ composer require wandi/i18n-bundle

Registering the bundle

$bundles = [
    // ...
    new \Wandi\I18nBundle\WandiI18nBundle(),
];

How to use

Entity

  • Add TranslatableEntity trait in your Entity.
  • Create many fields as needed foreach languages used.
class Foo
{
    use TranslatableEntity;
    
    // ...
    
    /**
     * @var string
     *
     * @ORM\Column(name="bar_fr", type="string", length=255)
     */
    private $barFr;
    
    /**
     * @var string
     *
     * @ORM\Column(name="bar_en", type="string", length=255)
     */
    private $barEn;
}

View and Controller

  • The trait will automatically use the correct getter depending to the current language used.

View

{{ Foo.bar }}

Controller

$foo->getBar();