小编Mar*_*708的帖子

如何在使用翻译行为时查询翻译的内容?

我的网站有多种语言,因此文章的标题取决于当地.但是有一个问题:我如何搜索另一种语言的文章?

现在,唯一的方法是用英文键入标题,以便cakePHP用法语检索名称,例如.我不能用法语搜索它.

例如:当我搜索"你好"时,我找到了一篇名为"Bonjour"的文章但是当我搜索"Bonjour"时,我找不到任何文章.

那么如何使用其他语言进行搜索?似乎Cakephp首先使用默认语言进行搜索,然后进行转换.

在我的控制器中:

$this->Ingredients->locale('fr_CA');
$data = $this->Ingredients->find('all')
->select([
    'Ingredients.id',
    'Ingredients.name'
])
->where(["Ingredients.name LIKE '%".$this->request->query['k']."%'"])
->order('Ingredients.recipe_count');
Run Code Online (Sandbox Code Playgroud)

php cakephp internationalization cakephp-3.0

2
推荐指数
1
解决办法
929
查看次数

标签 统计

cakephp ×1

cakephp-3.0 ×1

internationalization ×1

php ×1