Php 如何检查和查看推进对象是否有i18n记录?

Php 如何检查和查看推进对象是否有i18n记录?,php,internationalization,symfony1,propel,Php,Internationalization,Symfony1,Propel,我使用的是symfony和spreep,我试图在一个对象上调用一个特定的区域性,并将该对象的一些字段以该特定的区域性输出到屏幕上。但是,如果对象的映射数据库记录在该特定区域性中没有这些字段,我希望它默认为基本区域性(在本例中为en_US) 我是这样做的: $currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture); if($currentLesson->cultureExists($lessonCul

我使用的是symfony和spreep,我试图在一个对象上调用一个特定的区域性,并将该对象的一些字段以该特定的区域性输出到屏幕上。但是,如果对象的映射数据库记录在该特定区域性中没有这些字段,我希望它默认为基本区域性(在本例中为en_US)

我是这样做的:

$currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);
if($currentLesson->cultureExists($lessonCulture) $currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);
但是当我这样输出的时候

$currentLesson->getTitle();
如果没有区域性记录,则输出空字符串。我的问题是,如果我指定的某个culture不可用,是否有方法将对象默认为特定culture,或者是否有方法查看特定对象是否具有culture i18n记录

大概是这样的:

$currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);
if($currentLesson->cultureExists($lessonCulture) $currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);


您必须覆盖symfony本身,使其默认为另一种语言。
这里有一个很好的工作解决方案

您从
getTranslation($language)
返回的
i18n
记录可以使用
isNew()
进行测试,它将告诉您Speep是否刚刚编写了
(true)
,或者它是否来自数据库
(false)