本文整理汇总了PHP中CRM_Core_I18n::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_I18n::translate方法的具体用法?PHP CRM_Core_I18n::translate怎么用?PHP CRM_Core_I18n::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_I18n
的用法示例。
在下文中一共展示了CRM_Core_I18n::translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_3_2_beta4
/**
* @param $rev
*/
public function upgrade_3_2_beta4($rev)
{
$upgrade = new CRM_Upgrade_Form();
$config = CRM_Core_Config::singleton();
$seedLocale = $config->lcMessages;
//handle missing civicrm_uf_field.help_pre
$hasLocalizedPreHelpCols = FALSE;
// CRM-6451: for multilingual sites we need to find the optimal
// locale to use as the final civicrm_membership_status.name column
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$locales = array();
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
// optimal: an English locale
foreach (array('en_US', 'en_GB', 'en_AU') as $loc) {
if (in_array($loc, $locales)) {
$seedLocale = $loc;
break;
}
}
// if no English and no $config->lcMessages: use the first available
if (!$seedLocale) {
$seedLocale = $locales[0];
}
$upgrade->assign('seedLocale', $seedLocale);
$upgrade->assign('locales', $locales);
$localizedColNames = array();
foreach ($locales as $loc) {
$localizedName = "help_pre_{$loc}";
$localizedColNames[$localizedName] = $localizedName;
}
$columns = CRM_Core_DAO::executeQuery('SHOW COLUMNS FROM civicrm_uf_field');
while ($columns->fetch()) {
if (strpos($columns->Field, 'help_pre') !== FALSE && in_array($columns->Field, $localizedColNames)) {
$hasLocalizedPreHelpCols = TRUE;
break;
}
}
}
$upgrade->assign('hasLocalizedPreHelpCols', $hasLocalizedPreHelpCols);
$upgrade->processSQL($rev);
// now civicrm_membership_status.name has possibly localised strings, so fix them
$i18n = new CRM_Core_I18n($seedLocale);
$statuses = array(array('name' => 'New', 'start_event' => 'join_date', 'end_event' => 'join_date', 'end_event_adjust_unit' => 'month', 'end_event_adjust_interval' => '3', 'is_current_member' => '1', 'is_admin' => '0', 'is_default' => '0', 'is_reserved' => '0'), array('name' => 'Current', 'start_event' => 'start_date', 'end_event' => 'end_date', 'is_current_member' => '1', 'is_admin' => '0', 'is_default' => '1', 'is_reserved' => '0'), array('name' => 'Grace', 'start_event' => 'end_date', 'end_event' => 'end_date', 'end_event_adjust_unit' => 'month', 'end_event_adjust_interval' => '1', 'is_current_member' => '1', 'is_admin' => '0', 'is_default' => '0', 'is_reserved' => '0'), array('name' => 'Expired', 'start_event' => 'end_date', 'start_event_adjust_unit' => 'month', 'start_event_adjust_interval' => '1', 'is_current_member' => '0', 'is_admin' => '0', 'is_default' => '0', 'is_reserved' => '0'), array('name' => 'Pending', 'start_event' => 'join_date', 'end_event' => 'join_date', 'is_current_member' => '0', 'is_admin' => '0', 'is_default' => '0', 'is_reserved' => '1'), array('name' => 'Cancelled', 'start_event' => 'join_date', 'end_event' => 'join_date', 'is_current_member' => '0', 'is_admin' => '0', 'is_default' => '0', 'is_reserved' => '0'), array('name' => 'Deceased', 'is_current_member' => '0', 'is_admin' => '1', 'is_default' => '0', 'is_reserved' => '1'));
$statusIds = array();
$insertedNewRecord = FALSE;
foreach ($statuses as $status) {
$dao = new CRM_Member_DAO_MembershipStatus();
// try to find an existing English status
$dao->name = $status['name'];
// // if not found, look for translated status name
// if (!$dao->find(true)) {
// $found = false;
// $dao->name = $i18n->translate($status['name']);
// }
// if found, update name and is_reserved
if ($dao->find(TRUE)) {
$dao->name = $status['name'];
$dao->is_reserved = $status['is_reserved'];
if ($status['is_reserved']) {
$dao->is_active = 1;
}
// if not found, prepare a new row for insertion
} else {
$insertedNewRecord = TRUE;
foreach ($status as $property => $value) {
$dao->{$property} = $value;
}
$dao->weight = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
}
// add label (translated name) and save (UPDATE or INSERT)
$dao->label = $i18n->translate($status['name']);
$dao->save();
$statusIds[$dao->id] = $dao->id;
}
//disable all status those are customs.
if ($insertedNewRecord) {
$sql = '
UPDATE civicrm_membership_status
SET is_active = 0
WHERE id NOT IN ( ' . implode(',', $statusIds) . ' )';
CRM_Core_DAO::executeQuery($sql);
}
}