本文整理汇总了PHP中Translate::getPdfTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::getPdfTranslation方法的具体用法?PHP Translate::getPdfTranslation怎么用?PHP Translate::getPdfTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::getPdfTranslation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smartyTranslate
function smartyTranslate($params, &$smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']);
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : false;
if ($pdf) {
return Translate::getPdfTranslation($params['s']);
}
$filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
// If the template is part of a module
if (!empty($params['mod'])) {
return Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf);
}
// If the tpl is at the root of the template folder
if (dirname($filename) == '.') {
$class = 'index';
} elseif (strpos($filename, 'helpers') === 0) {
$class = 'Helper';
} else {
// Split by \ and / to get the folder tree for the file
$folder_tree = preg_split('#[/\\\\]#', $filename);
$key = array_search('controllers', $folder_tree);
// If there was a match, construct the class name using the child folder name
// Eg. xxx/controllers/customers/xxx => AdminCustomers
if ($key !== false) {
$class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true);
} else {
$class = null;
}
}
return Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf);
}
示例2: smartyTranslate
function smartyTranslate($params, &$smarty)
{
global $_LANG;
if (!isset($params['js'])) {
$params['js'] = false;
}
if (!isset($params['pdf'])) {
$params['pdf'] = false;
}
if (!isset($params['mod'])) {
$params['mod'] = false;
}
if (!isset($params['sprintf'])) {
$params['sprintf'] = null;
}
$string = str_replace('\'', '\\\'', $params['s']);
$filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
$basename = basename($filename, '.tpl');
$key = $basename . '_' . md5($string);
if (isset($smarty->source) && strpos($smarty->source->filepath, DIRECTORY_SEPARATOR . 'override' . DIRECTORY_SEPARATOR) !== false) {
$key = 'override_' . $key;
}
if ($params['mod']) {
return Translate::getModuleTranslation($params['mod'], $params['s'], $basename, $params['sprintf'], $params['js']);
} else {
if ($params['pdf']) {
return Translate::getPdfTranslation($params['s']);
}
}
if ($_LANG != null && isset($_LANG[$key])) {
$msg = $_LANG[$key];
} elseif ($_LANG != null && isset($_LANG[Tools::strtolower($key)])) {
$msg = $_LANG[Tools::strtolower($key)];
} else {
$msg = $params['s'];
}
if ($msg != $params['s'] && !$params['js']) {
$msg = stripslashes($msg);
} elseif ($params['js']) {
$msg = addslashes($msg);
}
if ($params['sprintf'] !== null) {
$msg = Translate::checkAndReplaceArgs($msg, $params['sprintf']);
}
return $params['js'] ? $msg : Tools::safeOutput($msg);
}
示例3: smartyTranslate
function smartyTranslate($params, &$smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']) || isset($params['js']);
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : array();
if (!empty($params['d'])) {
if (isset($params['tags'])) {
$backTrace = debug_backtrace();
$errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
}
}
if (!is_array($sprintf)) {
$backTrace = debug_backtrace();
$errorMessage = sprintf('Unable to translate "%s" in %s. sprintf() parameter should be an array.', $params['s'], $backTrace[0]['args'][1]->template_resource);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
return $params['s'];
}
}
return Context::getContext()->getTranslator()->trans($params['s'], $sprintf, $params['d']);
}
if ($pdf) {
return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $sprintf), $params);
}
$filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
// If the template is part of a module
if (!empty($params['mod'])) {
return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf, isset($params['js'])), $params);
}
// If the tpl is at the root of the template folder
if (dirname($filename) == '.') {
$class = 'index';
}
// If the tpl is used by a Helper
if (strpos($filename, 'helpers') === 0) {
$class = 'Helper';
} else {
// If the tpl is used by a Controller
if (!empty(Context::getContext()->override_controller_name_for_translations)) {
$class = Context::getContext()->override_controller_name_for_translations;
} elseif (isset(Context::getContext()->controller)) {
$class_name = get_class(Context::getContext()->controller);
$class = substr($class_name, 0, strpos(Tools::strtolower($class_name), 'controller'));
} else {
// Split by \ and / to get the folder tree for the file
$folder_tree = preg_split('#[/\\\\]#', $filename);
$key = array_search('controllers', $folder_tree);
// If there was a match, construct the class name using the child folder name
// Eg. xxx/controllers/customers/xxx => AdminCustomers
if ($key !== false) {
$class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true);
} elseif (isset($folder_tree[0])) {
$class = 'Admin' . Tools::toCamelCase($folder_tree[0], true);
}
}
}
return Translate::smartyPostProcessTranslation(Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf), $params);
}
示例4: l
/**
* Translation method
*
* @param string $string
*
* @return string translated text
*/
protected static function l($string)
{
return Translate::getPdfTranslation($string);
}
示例5: smartyTranslate
function smartyTranslate($params, &$smarty)
{
global $_LANG;
if (!isset($params['js'])) {
$params['js'] = false;
}
if (!isset($params['pdf'])) {
$params['pdf'] = false;
}
if (!isset($params['mod'])) {
$params['mod'] = false;
}
if (!isset($params['sprintf'])) {
$params['sprintf'] = array();
}
if (!isset($params['d'])) {
$params['d'] = null;
}
if (!is_null($params['d'])) {
if (isset($params['tags'])) {
$backTrace = debug_backtrace();
$errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
}
}
if (!is_array($params['sprintf'])) {
$backTrace = debug_backtrace();
$errorMessage = sprintf('Unable to translate "%s" in %s. sprintf() parameter should be an array.', $params['s'], $backTrace[0]['args'][1]->template_resource);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
return $params['s'];
}
}
}
if (($translation = Context::getContext()->getTranslator()->trans($params['s'], $params['sprintf'], $params['d'])) !== $params['s']) {
return $translation;
}
$string = str_replace('\'', '\\\'', $params['s']);
$filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
$basename = basename($filename, '.tpl');
$key = $basename . '_' . md5($string);
if (isset($smarty->source) && strpos($smarty->source->filepath, DIRECTORY_SEPARATOR . 'override' . DIRECTORY_SEPARATOR) !== false) {
$key = 'override_' . $key;
}
if ($params['mod']) {
return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], $basename, $params['sprintf'], $params['js']), $params);
} elseif ($params['pdf']) {
return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $params['sprintf']), $params);
}
if ($_LANG != null && isset($_LANG[$key])) {
$msg = $_LANG[$key];
} elseif ($_LANG != null && isset($_LANG[Tools::strtolower($key)])) {
$msg = $_LANG[Tools::strtolower($key)];
} else {
$msg = $params['s'];
}
if ($msg != $params['s'] && !$params['js']) {
$msg = stripslashes($msg);
} elseif ($params['js']) {
$msg = addslashes($msg);
}
if ($params['sprintf'] !== null) {
$msg = Translate::checkAndReplaceArgs($msg, $params['sprintf']);
}
return Translate::smartyPostProcessTranslation($params['js'] ? $msg : Tools::safeOutput($msg), $params);
}