symfony - Symfony4:不应用验证约束翻译
问题描述
语境
我正在开发一个带有 OroPlatform 覆盖的 Symfony 4 应用程序。
我已遵循本教程:https ://symfony.com/doc/4.4/validation/translations.html
这是我的代码:
<?php
/**
* @ORM\Entity(repositoryClass="Baltimore\Bundle\AppBundle\Repository\SubscriptionRepository")
* @ORM\Table(name="app_subscription")
*/
class Subscription
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*
* @var int
*/
private $id;
/**
* @ORM\Column(type="integer")
* @Assert\NotBlank(message="author.name.not_blank")
* @Assert\Type(type="integer")
*
* @var int
*/
private $number;
}
如您所见,我已将此行更改为默认NotBlank
消息@Assert\NotBlank(message="author.name.not_blank")
问题
我当前的语言环境是fr_FR
,我检查了以下代码:
<?php
$locale = $request->getLocale();
这是我的translations/validators.fr_FR.xlf
(路径相对于项目根目录):
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="fr" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="author.name.not_blank">
<source>author.name.not_blank</source>
<target>Veuillez entrer un nom d'auteur</target>
</trans-unit>
</body>
</file>
</xliff>
缓存被清除symfony console cache:clear
但是没有任何改变,错误信息author.name.not_blank
不是我的翻译。
命令行的输出php bin/console debug:translation fr BaltimoreAppBundle
:
解决方案
这似乎是因为 OroPlatform 有自己的命令行来更新翻译。
这是我的工作配置:
# /translations/validators.fr_FR.yml
This value should not be blank.: Cette valeur ne doit pas être vide
然后,我运行这些命令:php bin/console clear:cache
和php bin/console oro:translation:dump
现在我可以看到我更新的翻译。
推荐阅读
- database - 方法 db.collection.remove 未实现
- html - 从根目录打开 index.html 文件时找不到图像和动画
- mongodb - 使用 MongoDB 对 $[] 中的对象索引使用标识符
- css - 悬停CSS上的按钮颜色变化
- python - 我无法正确输入形状
- postgresql - 数据库未在 postgres (psql) 中创建
- react-native - React Native - 堆叠应用程序标题内容
- c# - 连接泄漏 (C#/ADO.NET) 即使使用使用创建的 SqlConnection
- node.js - 在 Heroku 上托管时,Puppeteer discord bot 不断崩溃
- angular - 在 Angular 2.2 中创建组件的错误在哪里?