我正在为 Symfony 2.3 中的默认语言环境选项苦苦挣扎。无论用户的浏览器设置是什么,我的应用程序都应该是英文的。
现在我收到了德语表单组件的验证消息(因为我使用的是德语浏览器):
我的配置设置是:
//config.yml
framework:
  translator:      { fallback: en }
  default_locale:  en
// parameters.yml
locale: en
// base.html.twig
<!DOCTYPE html>
<html lang="en">
...
编辑
一种解决方案是将自定义 html5 验证消息添加到表单元素。还有其他选择吗?
$builder->add('pname', 'text', array(
                "label" => "Internal name:",
                "required" => true,
                "attr" => array(
                    'class' => 'input-xxlarge required',
                    'oninvalid'=> "setCustomValidity('Please do this and that ')"
                )
            )
);