CakePHP的似乎是添加的“遏制”关联,它的确定,如果该物业位于实体对象的内部,而不是保存的关联,因为它会打破了很多东西阵列中的财产“_locale”,这只是发生在语言不是默认和模型的翻译行为,就如何解决任何想法/删除吗?
[product_variations] => Array(
[0] => App\Model\Entity\ProductsVariation Object(
[id] => 15
[product_id] => 12
[name] => Adults
[description] => <p>Adult Ticket</p>
[price_mode] => final
[price] => 15
[stock] => -1
[weight] => 0
[sku] => OITGXNRMARTPPDV
[data] =>
[active] => 1
[enquire] =>
[position] => 1
[products_prices] => Array
(
)
[_locale] => pt
[[new]] =>
[[accessible]] => Array
(
[*] => 1
)
[[dirty]] => Array
(
)
[[original]] => Array
(
)
[[virtual]] => Array
(
)
[[errors]] => Array
(
)
[[invalid]] => Array
(
)
[[repository]] => ProductVariations
),
[_locale] => pt
)
更新:似乎是由于使用了“匹配”的方法“型号 - >找到(...) - >匹配(‘ProductVariations’)...
所以,你保存你的第一篇文章后,您现在可以节省翻译它,有几种方法可以做到这一点。第一种是直接设置语言转化为实体:
$article->_locale = 'es';
$article->title = 'Mi primer Artículo';
$this->Articles->save($article);
所以,要认识到这一点,当你修改数据。我不知道,如果你删除它,然后保存记录或尝试用它做一些相关的别的国际化会发生什么。 :)
与此相关的财产is here in the TranslateTrait的代码。
您可以尝试通过调用formatResults()查询和取消设置该属性从那里添加result formatter。