本文整理汇总了PHP中Translate::getModuleTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::getModuleTranslation方法的具体用法?PHP Translate::getModuleTranslation怎么用?PHP Translate::getModuleTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::getModuleTranslation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: l
public static function l($string, $specific = false, $name = '')
{
if (empty($name)) {
$name = self::MODULE_NAME;
}
return Translate::getModuleTranslation($name, $string, $specific ? $specific : $name);
}
示例2: getAdminTranslation
/**
* Get a translation for an admin controller
*
* @param $string
* @param string $class
* @param bool $addslashes
* @param bool $htmlentities
* @return string
*/
public static function getAdminTranslation($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true, $sprintf = null)
{
static $modules_tabs = null;
// @todo remove global keyword in translations files and use static
global $_LANGADM;
if ($modules_tabs === null) {
$modules_tabs = Tab::getModuleTabList();
}
if ($_LANGADM == null) {
$iso = Context::getContext()->language->iso_code;
include_once _PS_TRANSLATIONS_DIR_ . $iso . '/admin.php';
}
if (isset($modules_tabs[strtolower($class)])) {
$class_name_controller = $class . 'controller';
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
if (class_exists($class_name_controller) && Module::getModuleNameFromClass($class_name_controller)) {
$string = str_replace('\'', '\\\'', $string);
return Translate::getModuleTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller);
}
}
$key = md5(str_replace('\'', '\\\'', $string));
if (isset($_LANGADM[$class . $key])) {
$str = $_LANGADM[$class . $key];
} else {
$str = Translate::getGenericAdminTranslation($string, $key, $_LANGADM);
}
if ($htmlentities) {
$str = htmlentities($str, ENT_QUOTES, 'utf-8');
}
$str = str_replace('"', '"', $str);
if ($sprintf !== null) {
$str = Translate::checkAndReplaceArgs($str, $sprintf);
}
return $addslashes ? addslashes($str) : stripslashes($str);
}
示例3: 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);
}
示例4: 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);
}
示例5: l
/**
* Uses translations files to find a translation for a given string (string should be in english).
*
* @param string $string term or expression in english
* @param string $class
* @param bool $addslashes if set to true, the return value will pass through addslashes(). Otherwise, stripslashes().
* @param bool $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8')
* @return string The translation if available, or the english default text.
*/
protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true)
{
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
$current_class = get_class($this);
if (Module::getModuleNameFromClass($current_class)) {
$string = str_replace('\'', '\\\'', $string);
return Translate::getModuleTranslation(Module::$classInModule[$current_class], $string, $current_class);
}
global $_LANGADM;
if ($class == __CLASS__) {
$class = 'AdminTab';
}
$key = md5(str_replace('\'', '\\\'', $string));
$str = array_key_exists(get_class($this) . $key, $_LANGADM) ? $_LANGADM[get_class($this) . $key] : (array_key_exists($class . $key, $_LANGADM) ? $_LANGADM[$class . $key] : $string);
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
return str_replace('"', '"', $addslashes ? addslashes($str) : stripslashes($str));
}
示例6: l
protected function l($string)
{
return Translate::getModuleTranslation($this->module, $string, Tools::getValue('controller'));
}
示例7: l
protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true)
{
return Translate::getModuleTranslation($this->module, $string, Tools::getValue('controller'));
}
示例8: postProcess
public function postProcess()
{
if (Tools::isSubmit('sendCampaign')) {
$yes = (string) Tools::getValue('YES', '');
$yes = Tools::strtoupper($yes);
if ($yes == Tools::strtoupper(Translate::getModuleTranslation('expressmailing', 'YES', 'footer_validation'))) {
if ($this->sendCampaignAPI()) {
$this->confirmations[] = $this->module->l('Your campaign is now sending ...', 'adminmarketingestep8');
// Tracking Prestashop
// -------------------
return Db::getInstance()->update('expressmailing_email', array('campaign_state' => '1', 'campaign_api_validation' => '1'), 'campaign_id = ' . $this->campaign_id);
}
} else {
$this->errors[] = sprintf($this->module->l('Please fill the %s field', 'adminmarketingestep8'), '« ' . Translate::getModuleTranslation('expressmailing', 'YES', 'footer_validation') . ' »');
}
return false;
}
}
示例9: convertDocToFaxAPI
private function convertDocToFaxAPI($filename, $file_path)
{
$suffix = pathinfo((string) $filename, PATHINFO_EXTENSION);
$file_data = Tools::file_get_contents((string) $file_path);
$encoded_file_data = mb_convert_encoding($file_data, 'BASE64', 'UTF-8');
$response_array = null;
$parameters = array('application_id' => Translate::getModuleTranslation('expressmailing', '3320', 'session_api'), 'file_suffix' => 'prestashop.' . $suffix, 'document' => $encoded_file_data, 'return_format' => 'Png');
if ($this->session_api->call('fax', 'tools', 'convert_doc_to_fax', $parameters, $response_array)) {
return $response_array;
} else {
return false;
}
}
示例10: l
/**
* use translations files to replace english expression.
*
* @param mixed $string term or expression in english
* @param string $class
* @param boolan $addslashes if set to true, the return value will pass through addslashes(). Otherwise, stripslashes().
* @param boolean $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8')
* @return string the translation if available, or the english default text.
*/
protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true)
{
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
$currentClass = get_class($this);
if (Module::getModuleNameFromClass($currentClass)) {
return Translate::getModuleTranslation(Module::$classInModule[$currentClass], $string, $currentClass);
}
return Translate::getAdminTranslation($string, get_class($this), $addslashes, $htmlentities);
}
示例11: l
private function l($string)
{
return Translate::getModuleTranslation('expressmailing', $string, 'session_api');
}
示例12: l
/**
* @see Module::l
*/
private static function l($string, $specific = false)
{
if (version_compare(_PS_VERSION_, '1.5.0.13', "<=")) {
return PKHelper::$_module->l($string, $specific ? $specific : 'pkhelper');
}
return Translate::getModuleTranslation('piwikanalyticsjs', $string, $specific ? $specific : 'pkhelper');
// the following lines are need for the translation to work properly
// $this->l('I need Site ID and Auth Token before i can get your image tracking code')
// $this->l('E-commerce is not active for your site in piwik!, you can enable it in the advanced settings on this page')
// $this->l('Site search is not active for your site in piwik!, you can enable it in the advanced settings on this page')
// $this->l('Unable to connect to api %s')
// $this->l('E-commerce is not active for your site in piwik!')
// $this->l('Site search is not active for your site in piwik!')
// $this->l('A password is required for method PKHelper::getTokenAuth()!')
}
示例13: l
protected function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
return Translate::getModuleTranslation('chronopost', $string, Tools::substr(get_class($this), 0, -10), null, false);
}
示例14: postProcess
public function postProcess()
{
// On construit un login pour le compte
// ------------------------------------
// Si PS_SHOP_EMAIL = info@axalone.com
// Alors login = ps-info-axalone
// 1/ On ajoute 'ps-' devant l'email
// 2/ On retire l'extention .com à la fin
// 3/ On remplace toutes les lettres accentuées par leurs équivalents sans accent
// 4/ On remplace tous les sigles par des tirets
// 5/ Enfin on remplace les doubles/triples tirets par des simples
// --------------------------------------------------------------------------------
$company_login = 'ps-' . Configuration::get('PS_SHOP_EMAIL');
$company_login = Tools::substr($company_login, 0, strrpos($company_login, '.'));
$company_login = EMTools::removeAccents($company_login);
$company_login = Tools::strtolower($company_login);
$company_login = preg_replace('/[^a-z0-9-]/', '-', $company_login);
$company_login = preg_replace('/-{2,}/', '-', $company_login);
$cart_product = (string) Tools::getValue('product', '');
// Initialisation de l'API
// -----------------------
if (Tools::isSubmit('submitInscription')) {
// On prépare l'ouverture du compte
// --------------------------------
$company_name = (string) Tools::getValue('company_name');
$company_email = (string) Tools::getValue('company_email');
$company_phone = (string) Tools::getValue('company_phone');
$company_address1 = (string) Tools::getValue('company_address1');
$company_address2 = (string) Tools::getValue('company_address2');
$company_zipcode = (string) Tools::getValue('company_zipcode');
$company_city = (string) Tools::getValue('company_city');
$country_id = (int) Tools::getValue('country_id');
$country = new Country($country_id);
if (!is_object($country) || empty($country->id)) {
$this->errors[] = Tools::displayError('Country is invalid');
} else {
$company_country = Country::getNameById($this->context->language->id, $country_id);
}
if (!Validate::isGenericName($company_name)) {
$this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop name', 'AdminStores') . ' »');
}
if (!Validate::isEmail($company_email)) {
$this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop email', 'AdminStores') . ' »');
}
if (!Validate::isPhoneNumber($company_phone)) {
$this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Phone', 'AdminStores') . ' »');
}
if (!Validate::isAddress($company_address1)) {
$this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' »');
}
if ($country->zip_code_format && !$country->checkZipCode($company_zipcode)) {
$this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)));
} elseif (empty($company_zipcode) && $country->need_zip_code) {
$this->errors[] = Tools::displayError('A Zip/postal code is required.');
} elseif ($company_zipcode && !Validate::isPostCode($company_zipcode)) {
$this->errors[] = Tools::displayError('The Zip/postal code is invalid.');
}
if (!Validate::isGenericName($company_city)) {
$this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('City', 'AdminStores') . ' »');
}
// We save these informations in the database
// ------------------------------------------
Db::getInstance()->insert('expressmailing_order_address', array('id_address' => 1, 'company_name' => pSQL($company_name), 'company_email' => pSQL($company_email), 'company_address1' => pSQL($company_address1), 'company_address2' => pSQL($company_address2), 'company_zipcode' => pSQL($company_zipcode), 'company_city' => pSQL($company_city), 'country_id' => $country_id, 'company_country' => pSQL($company_country), 'company_phone' => pSQL($company_phone), 'product' => pSQL($cart_product)), false, false, Db::REPLACE);
// If form contains 1 or more errors, we stop the process
// ------------------------------------------------------
if (is_array($this->errors) && count($this->errors)) {
return false;
}
// Open a session on Express-Mailing API
// -------------------------------------
if ($this->session_api->openSession()) {
// We create the account
// ---------------------
$response_array = array();
$base_url = Configuration::get('PS_SSL_ENABLED') == 0 ? Tools::getShopDomain(true, true) : Tools::getShopDomainSsl(true, true);
$module_dir = Tools::str_replace_once(_PS_ROOT_DIR_, '', _PS_MODULE_DIR_);
$parameters = array('login' => $company_login, 'info_company' => $company_name, 'info_email' => $company_email, 'info_phone' => $company_phone, 'info_address' => $company_address1 . "\r\n" . $company_address2, 'info_country' => $company_country, 'info_zipcode' => $company_zipcode, 'info_city' => $company_city, 'info_phone' => $company_phone, 'info_contact_firstname' => $this->context->employee->firstname, 'info_contact_lastname' => $this->context->employee->lastname, 'email_report' => $this->context->employee->email, 'gift_code' => 'prestashop_' . Translate::getModuleTranslation('expressmailing', '3320', 'session_api'), 'INFO_WWW' => $base_url . $module_dir . $this->module->name . '/campaigns/index.php');
if ($this->session_api->createAccount($parameters, $response_array)) {
// If the form include the buying process (field 'product')
// We initiate a new cart with the product selected
// --------------------------------------------------------
if ($cart_product) {
Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy'));
exit;
}
// Else we back to the mailing process
// -----------------------------------
Tools::redirectAdmin($this->next_action);
exit;
}
if ($this->session_api->error == 11) {
// Account already existe, we print the rescue form (with password input)
// ----------------------------------------------------------------------
$response_array = array();
$parameters = array('login' => $company_login);
$this->session_api->resendPassword($parameters, $response_array);
$this->generateRescueForm();
return;
} else {
// Other error
//.........这里部分代码省略.........
示例15: 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);
}