我需要在symfony 3.4中进行翻译的帮助。
我正在使用Bundle KnpLabs / DoctrineBehaviors,并希望在控制器中设置翻译。
$data = [
"token" => "jksdlfnhvbji89erje%&",
"data" => [
["locale" => "en", "content" => "Value1"],
["locale" => "de", "content" => "Value2"],
]
];
foreach($data['data'] as $item){
$firma->translate($item['locale'], true)->setKurzBeschreibung( $value );
}
$em->persist($firma);
$firma->mergeNewTranslations();
$result = $em->flush();
一切都第一次正常。 现在我想更改值:
$data = [
"token" => "jksdlfnhvbji89erje%&",
"data" => [
["locale" => "en", "content" => ""],
["locale" => "de", "content" => "Value2"],
]
];
foreach($data['data'] as $item){
$firma->translate($item['locale'], true)->setKurzBeschreibung( $value );
}
$em->persist($firma);
$firma->mergeNewTranslations();
$result = $em->flush();
工作正常。现在
$data = [
"token" => "jksdlfnhvbji89erje%&",
"data" => [
["locale" => "en", "content" => "Value1"],
["locale" => "de", "content" => "Value2"],
]
];
foreach($data['data'] as $item){
$firma->translate($item['locale'], true)->setKurzBeschreibung( $value );
}
$em->persist($firma);
$firma->mergeNewTranslations();
$result = $em->flush();
不存储en的“内容”。表中的字段仍然为空。
我能做什么?