Symfony2.1 FosUserBundle翻译坏了

时间:2013-02-15 03:46:11

标签: symfony-2.1 fosuserbundle

我有一个Symfony 2.0和FOSUserBundle 1.2.0的项目,一切都运行良好。当我从主分支升级到最新的Symfony 2.1版本和最新的FOSUserBundle时,在修复了大量内容之后,标签没有被翻译,即“form.username”。

我的用户捆绑包被我制作的自定义捆绑包覆盖了。我已经覆盖了以下内容:

  • 控制器

    • ChangePasswordController
    • GroupController
    • 这个RegistrationController
    • UserController中
  • 表格

    • 类型
      • ChangePasswordFormType
      • RegistrationFormType
  • 资源

    • 配置
      • 的routing.yml
    • 的观点
      • ChangePassword
        • changePassword_content.html.twig
        • changePassword.html.twig
        • form_group.html.twig
        • form_user.html.twig
        • edit.html.twig
        • list.html.twig
        • new.html.twig
        • show.html.twig
      • 注册
        • checkEmail.html.twig
        • email.txt.twig
        • register_content.html.twig
        • register.html.twig
      • 用户
        • edit.html.twig
        • index.html.twig
        • show.html.twig

我还有一个自定义用户和组实体,以及我在上一个树中省略的自定义UserType和GroupType。

翻译文件位于app / Resources / translations / FOSUserBundle.en.yml 我也尝试将它们复制到我的包中,src / Acme / UserBundle / Resources / translations / FOSUserBundle.en.yml 他们都没有使用symfony 2.1。

当然,为了以防万一,我清理了缓存,生产缓存和重新生成的资产,并刷新了浏览器...一切都好几次都没有。

我在这里和谷歌搜索过,我找不到任何线索,我尝试了一些但却没有成功。

我将复制下面某些文件的内容。

  

的Acme / UserBundle /控制器/ RegistrationController.php

<?php

namespace Acme\UserBundle\Controller;

use Symfony\Component\HttpFoundation\RedirectResponse;

class RegistrationController extends BaseController
{
public function registerAction()
{
    $form = $this->container->get('fos_user.registration.form');
    $formHandler = $this->container->get('fos_user.registration.form.handler');
    $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');

    $process = $formHandler->process($confirmationEnabled);
    if ($process) {
        $user = $form->getData();

        $authUser = false;
        if ($confirmationEnabled) {
            $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
            $route = 'fos_user_registration_check_email';
        } else {
            $authUser = true;
            $route = 'AcmeUserBundle_admin_user_index';
        }

        $this->setFlash('fos_user_success', 'registration.flash.user_created');
        $url = $this->container->get('router')->generate($route);
        $response = new RedirectResponse($url);

        if ($authUser) {
            $this->authenticateUser($user, $response);
        }

        return $response;
    }

    return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
        'form' => $form->createView(),
    ));
}
}
  

的Acme / UserBundle /窗体/类型/ RegistrationFormType.php

<?php

namespace Acme\UserBundle\Form\Type;

use Doctrine\ORM\EntityManager;

class RegistrationFormType extends BaseType
{
private $entityManager;

public function __construct($class, EntityManager $entityManager)
{
    parent::__construct($class);
    $this->entityManager = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'error_bubbling' => true))
        ->add('nombre', 'text', array('error_bubbling' => true))
        ->add('apellido', 'text', array('error_bubbling' => true))
        ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle', 'error_bubbling' => true))
        ->add('plainPassword', 'repeated', array(
                'type' => 'password',
                'options' => array('translation_domain' => 'FOSUserBundle'),
                'first_options' => array('label' => 'form.password'),
                'second_options' => array('label' => 'form.password_confirmation'),
                'invalid_message' => 'fos_user.password.mismatch',
                'error_bubbling' => true,
        ))
        ->add('groups', 'entity', array(
                'class' => 'Acme\\UserBundle\\Entity\\Group',
                'property' => 'name',
                'label' => 'Grupos',
                'empty_value' => 'Seleccione Grupos',
                'multiple'  =>  true,
                'expanded'  =>  true,
                'required'  =>  false,
        ));
}

public function getName()
{
    return 'acme_user_registration';
}    
}
  

的Acme /资源/视图/注册/ register_content.html.twig

<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
<div class="content no-padding" {{ block('container_attributes') }}>            
    {{ form_widget(form) }}
</div>
<div class="actions">
    <div class="actions-left" style="margin-top: 8px;"></div>
    <div class="actions-right">
        <input type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" />
    </div>
</div>    

  

的Acme /资源/视图/注册/ register.html.twig

{% extends "AcmeAdminBundle:Base:base_auth.html.twig" %}
{% form_theme form 'AcmeUserBundle:Form:form_user.html.twig' %}

*[...] Here are stylesheets and JS[...]*

{% block main_content %}
<!-- Start of the main content -->
<div id="main_content">
    <h2 class="grid_12">{% block title "Crear Usuario" %}</h2>
    <div class="clean"></div>
        <div class="grid_6">
            <div class="box">
                <div class="header">
                    <img src="{{ asset('bundles/acmeadmin/img/icons/packs/fugue/16x16/ui-text-field-format.png') }}" alt="" width="16"
                    height="16">
                    <h3>Información Básica</h3>
                    <span></span>
                </div>
                {% block fos_user_content %}
                    {% include "AcmeUserBundle:Registration:register_content.html.twig" %}
                {% endblock fos_user_content %}
            </div> <!-- End of .box -->
        </div> <!-- End of .grid_6 -->
</div> <!-- End of #main_content -->
<div class="push clear"></div>
{% endblock main_content %}

如果我禁用了我的捆绑包,请删除

    public function getParent()
{
    return 'FOSUserBundle';
}

标签按预期显示翻译。我不知道还能做什么。有什么建议吗?

0 个答案:

没有答案