项目作者: WandiParis

项目描述 :
Wandi i18n Bundle
高级语言: PHP
项目地址: git://github.com/WandiParis/I18nBundle.git
创建时间: 2017-11-16T14:01:23Z
项目社区:https://github.com/WandiParis/I18nBundle

开源协议:MIT License

下载


I18nBundle

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

Setup

Install via composer

  1. $ composer require wandi/i18n-bundle

Registering the bundle

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

How to use

Entity

  • Add TranslatableEntity trait in your Entity.
  • Create many fields as needed foreach languages used.
  1. class Foo
  2. {
  3. use TranslatableEntity;
  4. // ...
  5. /**
  6. * @var string
  7. *
  8. * @ORM\Column(name="bar_fr", type="string", length=255)
  9. */
  10. private $barFr;
  11. /**
  12. * @var string
  13. *
  14. * @ORM\Column(name="bar_en", type="string", length=255)
  15. */
  16. private $barEn;
  17. }

View and Controller

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

View

  1. {{ Foo.bar }}

Controller

  1. $foo->getBar();