本文整理匯總了PHP中Languages::findByLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::findByLocale方法的具體用法?PHP Languages::findByLocale怎麽用?PHP Languages::findByLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Languages
的用法示例。
在下文中一共展示了Languages::findByLocale方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
//.........這裏部分代碼省略.........
}
// if
// Cache of loaded languages
$languages = array();
// Get from email and from name
$from_email = ConfigOptions::getValue('notifications_from_email');
$from_name = ConfigOptions::getValue('notifications_from_name');
if (!is_valid_email($from_email)) {
$from_email = ADMIN_EMAIL;
}
// if
if (empty($from_name)) {
$from_name = $owner_company->getName();
}
// if
// Now prepare messages
foreach ($to as $recipient) {
$locale = $default_locale;
if (instance_of($recipient, 'User')) {
$locale = $recipient->getLocale($default_locale);
$recipient_name = $recipient->getDisplayName();
$recipient_email = $recipient->getEmail();
// If same reset name... "name@site.com <name@site.com>" can cause
// problems with some servers
if ($recipient_name == $recipient_email) {
$recipient_name = null;
}
// if
} else {
$recipient_name = null;
$recipient_email = $recipient;
}
// if
$language = isset($languages[$locale]) ? $languages[$locale] : Languages::findByLocale($locale);
// We have message prepared, just need to add a recipient
//BOF:mod
//if(isset($to_send[$locale])) {
if (isset($to_send[$locale]) && $tpl != 'resources/new_comment') {
//EOF:moid
$to_send[$locale]['recipients']->add($recipient_email, $recipient_name);
// Need to prepare message and add first recipient
} else {
//BOF:mod 20110711 ticketid231
if ($tpl == 'resources/new_comment') {
$mark_actionrequest_complete = '';
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$query = "select a.is_action_request, b.project_id from healingcrystals_assignments_action_request a inner join healingcrystals_project_objects b on a.comment_id=b.id where a.comment_id='" . $replacements['comment_id'] . "' and a.user_id='" . $recipient->getId() . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if ($info['is_action_request'] == '1') {
$mark_actionrequest_complete = '<div style="margin:5px 0 5px 0;"><a href="' . assemble_url('project_comment_action_request_completed', array('project_id' => $info['project_id'], 'comment_id' => $replacements['comment_id'])) . '">Click here to Mark this Action Request Complete</a></div>';
}
}
mysql_close($link);
$replacements['mark_actionrequest_complete'] = $mark_actionrequest_complete;
}
//EOF:mod 20110711 ticketid231
$subject = $template->getSubject($locale);
$body = $template->getBody($locale);
foreach ($replacements as $k => $v) {
if (is_array($v)) {
$v = isset($v[$locale]) ? $v[$locale] : array_shift($v);
}
// if
示例2: lang
/**
* Return $content in selected language and insert $params in it
*
* @param string $content
* @param array $params
* @param boolean $clean_params
* @param Language $language
* @return string
*/
function lang($content, $params = null, $clean_params = true, $language = null, $skip_custom_replacement = false)
{
if (LOCALIZATION_ENABLED) {
$locale = $language && instance_of($language, 'Language') ? $language->getLocale() : $GLOBALS['current_locale'];
if ($locale == BUILT_IN_LOCALE) {
$result = $content;
} else {
if (!isset($GLOBALS['current_locale_translations'][$locale])) {
if (!instance_of($language, 'Language')) {
$language = Languages::findByLocale($locale);
}
// if
if (instance_of($language, 'Language')) {
$GLOBALS['current_locale_translations'][$locale] = array();
$language->loadTranslations($locale);
} else {
$GLOBALS['current_locale_translations'][$locale] = null;
}
// if
}
// if
$result = isset($GLOBALS['current_locale_translations'][$locale]) && isset($GLOBALS['current_locale_translations'][$locale][$content]) && $GLOBALS['current_locale_translations'][$locale][$content] ? array_var($GLOBALS['current_locale_translations'][$locale], $content, $content) : $content;
}
// if
} else {
$result = $content;
}
// if
if (is_foreachable($params)) {
foreach ($params as $k => $v) {
$set = $clean_params ? clean($v) : $v;
$result = str_replace(":{$k}", $set, $result);
}
// foreach
}
// if
//BOF: mod
if (!$skip_custom_replacement) {
switch ($result) {
case 'Projects':
$result = 'Teams';
break;
case 'Project':
$result = 'Team';
break;
case 'Milestones':
$result = 'Projects';
break;
case 'Milestone':
$result = 'Project';
break;
default:
$pos = strpos($result, 'http');
if (!($pos !== false)) {
$pos = strpos($result, 'Projects');
if ($pos !== false) {
$result = str_replace('Projects', 'Teams', $result);
}
$pos = strpos($result, 'projects');
if ($pos !== false) {
$result = str_replace('projects', 'teams', $result);
}
$pos = strpos($result, 'Project');
if ($pos !== false) {
$result = str_replace('Project', 'Team', $result);
}
$pos = strpos($result, 'project');
if ($pos !== false) {
$result = str_replace('project', 'team', $result);
}
$pos = strpos($result, 'Milestones');
if ($pos !== false) {
$result = str_replace('Milestones', 'Projects', $result);
}
$pos = strpos($result, 'milestones');
if ($pos !== false) {
$result = str_replace('milestones', 'projects', $result);
}
$pos = strpos($result, 'Milestone');
if ($pos !== false) {
$result = str_replace('Milestone', 'Project', $result);
}
$pos = strpos($result, 'milestone');
if ($pos !== false) {
$result = str_replace('milestone', 'project', $result);
}
}
}
}
//EOF: mod
return $result;
//.........這裏部分代碼省略.........