0
我查詢所有的行從表中,我得到的所有排在所有語言......我怎麼能從i18n表中得到一個結果? (CakePHP的)
例如: GalleryCategoriesController.php
<?php
class GalleryCategoriesController extends AppController
{
function index()
{
$galleryCategories = $this->GalleryCategory->find('all');
print_r($galleryCategories);
$this->set('galleryCategories', $galleryCategories);
}
}
?>
GalleryCategory.php(模型)
<?php
class GalleryCategory extends AppModel
{
public $tablePrefix = 'ef_';
var $name = 'GalleryCategory';
public $actsAs = array('Translate' => array(
'title' => 'titleTranslation',
'title_sub' => 'titleSubTranslation',
'description' => 'descriptionTranslation'
)
);
}
?>
結果:
Array
(
[0] => Array
(
[GalleryCategory] => Array
(
[id] => 1
[gallery_category_id] => 0
[title] => Test title
[title_sub] => Test subtitle
[description] => Test description
[status] => 2
[locale] => hun
)
[titleTranslation] => Array
(
[0] => Array
(
[id] => 65
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => title
[content] => Test title hungarian
)
[1] => Array
(
[id] => 80
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => title
[content] => Test title english
)
)
[titleSubTranslation] => Array
(
[0] => Array
(
[id] => 66
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => title_sub
[content] => Test subtitle hungarian
)
[1] => Array
(
[id] => 81
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => title_sub
[content] => Test subtitle english
)
)
[descriptionTranslation] => Array
(
[0] => Array
(
[id] => 67
[locale] => hun
[model] => GalleryCategory
[foreign_key] => 1
[field] => description
[content] => Test description hungarian
)
[1] => Array
(
[id] => 82
[locale] => eng
[model] => GalleryCategory
[foreign_key] => 1
[field] => description
[content] => Test description english
)
)
)
)
我怎樣才能得到匈牙利語翻譯?因爲如果我在網站上有六種語言,並且我查詢了任何內容,我就可以用六種語言獲得它...這太可怕了......
謝謝!它正在工作! 但是,我使用此: '會話級>寫入( 'Config.language',$朗); \t \t \t} \t \t $ this-> redirect(Controller :: referer()); \t \t die; \t \t} \t} >' 因此,有沒有必要? '$這個 - > GalleryCategory->區域= ' –
2013-04-28 06:30:42