本文整理匯總了PHP中sfCultureInfo::getNativeName方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfCultureInfo::getNativeName方法的具體用法?PHP sfCultureInfo::getNativeName怎麽用?PHP sfCultureInfo::getNativeName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfCultureInfo
的用法示例。
在下文中一共展示了sfCultureInfo::getNativeName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getNativeName
public static function getNativeName($culture)
{
$cult = new sfCultureInfo($culture);
return $cult->getNativeName();
}
示例2: sfCultureInfo
$t->is($c->getIsNeutralCulture(), false, '->getIsNeutralCulture() returns false if the culture is specific');
$c = new sfCultureInfo('fr');
$t->is($c->getIsNeutralCulture(), true, '->getIsNeutralCulture() returns true if the culture is neutral');
// ->getEnglishName()
$t->diag('->getEnglishName()');
$c = new sfCultureInfo('fr_FR');
$t->is($c->getEnglishName(), 'French (France)', '->getEnglishName() returns the english name of the current culture');
$c = new sfCultureInfo('fr');
$t->is($c->getEnglishName(), 'French', '->getEnglishName() returns the english name of the current culture');
$t->is($c->getEnglishName(), $c->EnglishName, '->getEnglishName() is equivalent to ->EnglishName');
// ->getNativeName()
$t->diag('->getNativeName()');
$c = new sfCultureInfo('fr_FR');
$t->is($c->getNativeName(), 'français (France)', '->getNativeName() returns the native name of the current culture');
$c = new sfCultureInfo('fr');
$t->is($c->getNativeName(), 'français', '->getNativeName() returns the native name of the current culture');
$t->is($c->getNativeName(), $c->NativeName, '->getNativeName() is equivalent to ->NativeName');
// ->getCalendar()
$t->diag('->getCalendar()');
$c = new sfCultureInfo('fr');
$t->is($c->getCalendar(), 'gregorian', '->getCalendar() returns the default calendar');
$t->is($c->getCalendar(), $c->Calendar, '->getCalendar() is equivalent to ->Calendar');
// __get()
$t->diag('__get()');
try {
$c->NonExistant;
$t->fail('__get() throws an exception if the property does not exist');
} catch (sfException $e) {
$t->pass('__get() throws an exception if the property does not exist');
}
// __set()
示例3: executeEdit
public function executeEdit()
{
/** @var \myUser $sfUser */
$sfUser = sfContext::getInstance()->getUser();
$userId = $sfUser->getSubscriberId();
$schemaObj = $this->getCurrentSchema();
$CurrentCulture = $sfUser->getCulture();
//FIXME: If the user is an admin, set the available languages to all of the schema languages
//FIXME: if the user has no languages set, silently set their language to the default (?)
if ($userId) {
$c = new Criteria();
$c->add(SchemaHasUserPeer::USER_ID, $userId);
$c->add(SchemaHasUserPeer::SCHEMA_ID, $schemaObj->getId());
$schemaUser = SchemaHasUserPeer::doSelectOne($c);
if ($sfUser->hasObjectCredential($schemaObj->getId(), 'schema', array(0 => array(0 => 'administrator', 2 => 'schemaadmin')))) {
$UserLanguages = $schemaObj->getLanguages();
$DefaultLanguage = $schemaObj->getLanguage();
} else {
if ($schemaUser) {
$UserLanguages = $schemaUser->getLanguages();
$DefaultLanguage = $schemaUser->getDefaultLanguage();
} else {
//set the languages from the schema
$UserLanguages = $schemaObj->getLanguages();
$DefaultLanguage = $schemaObj->getLanguage();
}
}
if (is_array($UserLanguages) && !in_array($CurrentCulture, $UserLanguages)) {
//save the current culture
$UserCulture = $sfUser->getCulture();
$this->getUser()->setAttribute("UserCulture", $UserCulture);
//reset the current culture for edit
$sfUser->setCulture($DefaultLanguage);
$this->getUser()->setAttribute("CurrentLanguage", $DefaultLanguage);
$culture = new sfCultureInfo($this->getUser()->getCulture());
$this->setFlash('notice', 'Current language is not available for edit! Current editing language has been reset to: ' . $culture->getNativeName());
}
$this->getUser()->setAttribute("languages", $UserLanguages);
}
parent::executeEdit();
/** @var $schemaProperty SchemaProperty */
$schemaProperty = $this->schema_property;
if ($schemaProperty) {
$schemaObj = $this->getCurrentSchema();
$schemaProperty->setSchemaUri($schemaObj->getNamespace());
$lexUri = $schemaProperty->getLexicalAlias();
if (empty($lexUri)) {
$newURI = $schemaObj->getNamespace();
$this->setDefaultLexicalAlias($schemaProperty, $newURI);
}
}
}
示例4: getCurrentLanguage
public function getCurrentLanguage()
{
$c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
return $c->getNativeName();
}