juanber84/simplei18nbundle

此Bundle为Symfony2的翻译提供了一种简单解决方案。

安装: 12

依赖者: 0

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

dev-master 2014-03-18 08:32 UTC

This package is not auto-updated.

Last update: 2024-09-24 06:49:09 UTC


README

###使用composer安装

{
    "require": {
        "juanber84/simplei18nbundle": "dev-master"
    }
}

兼容https://symfony.com.cn/doc/current/cookbook/session/locale_sticky_session.html

在app/AppKernel.php中添加

<?php

   // app/AppKernel.php
   public function registerBundles()
   {
     return array(
       // ...
        new Juanber84\Bundle\Simplei18nBundle\Juanber84Simplei18nBundle(),
       // ...
     );
   }

在app/routing.yml中添加

juanber84_simplei18n:
    resource: "@Juanber84Simplei18nBundle/Resources/config/routing.yml"
    prefix:   /

###使用它

将以下twig代码放入布局的头部

{{ language('es') }} // If you used this it will convert to the language which you've inserted
{{ language() }}     // If you used this it will convert to the language which _locale var session

在显示widget的位置使用它

{{ simplei18n(['es', 'en', 'pt', 'it'] )|raw }}

使用路径创建自定义widget

{{ path('juanber84_simplei18n_changelocale', {'locale': 'es'}) }}