[*] BO: use Translate::getAdminTranslation instead of translate()

This commit is contained in:
PrestaEdit
2013-06-01 00:21:28 +02:00
parent 037f0e6d3c
commit 6ae0dbb4ca
5 changed files with 45 additions and 55 deletions

View File

@@ -30,14 +30,14 @@ echo ' </div>
<div id="footer">
<div style="float:left;margin-left:10px;padding-top:6px">
<a href="http://www.prestashop.com/" target="_blank" style="font-weight:700;color:#666666">PrestaShop&trade; '._PS_VERSION_.'</a><br />
<span style="font-size:10px">'.translate('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span>
<span style="font-size:10px">'.Translate::getAdminTranslation('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span>
</div>
<div style="float:right;height:40px;margin-right:10px;line-height:38px;vertical-align:middle">';
if (strtoupper(Context::getContext()->language->iso_code) == 'FR') echo '<span style="color: #812143; font-weight: bold;">Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h &agrave; 18h ';
echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.translate('Contact').'</a>
| <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.translate('Bug Tracker').'</a>
| <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.translate('Forum').'</a>
echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Contact').'</a>
| <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Bug Tracker').'</a>
| <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Forum').'</a>
</div>
</div>
</div>

View File

@@ -223,17 +223,6 @@ function checkPSVersion()
return $upgrader->checkPSVersion();
}
function translate($string)
{
global $_LANGADM;
if (!is_array($_LANGADM))
return str_replace('"', '&quot;', $string);
$key = md5(str_replace('\'', '\\\'', $string));
$str = (key_exists('index'.$key, $_LANGADM)) ? $_LANGADM['index'.$key] : ((key_exists('index'.$key, $_LANGADM)) ? $_LANGADM['index'.$key] : $string);
return str_replace('"', '&quot;', stripslashes($str));
}
/**
* Returns a new Tab object
*
@@ -461,7 +450,7 @@ function runAdminTab($tab, $ajaxMode = false)
echo '<div class="path_bar">
<div id="help-button" class="floatr" style="display: none; font-family: Verdana; font-size: 10px; margin-right: 4px; margin-top: 4px;">
</div>
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.translate('Back Office').'</a>
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.Translate::getAdminTranslation('Back Office').'</a>
'.$bread.'</div>';
if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
@@ -470,10 +459,10 @@ function runAdminTab($tab, $ajaxMode = false)
if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
printf(translate('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>');
printf(Translate::getAdminTranslation('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>');
}
elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
printf(translate('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
printf(Translate::getAdminTranslation('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo '</div>';
}
if (Validate::isLoadedObject($adminObj))
@@ -546,8 +535,8 @@ function runAdminTab($tab, $ajaxMode = false)
// we can display the correct url
// die(Tools::jsonEncode(array(translate('Invalid security token'),$url)));
die(Tools::jsonEncode(translate('Invalid security token')));
// die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url)));
die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token')));
}
else
{
@@ -559,17 +548,17 @@ function runAdminTab($tab, $ajaxMode = false)
if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
$url .= '&token='.$adminObj->token;
$message = translate('Invalid security token');
$message = Translate::getAdminTranslation('Invalid security token');
echo '<html><head><title>'.$message.'</title></head><body style="font-family:Arial,Verdana,Helvetica,sans-serif;background-color:#EC8686">
<div style="background-color:#FAE2E3;border:1px solid #000000;color:#383838;font-weight:700;line-height:20px;margin:0 0 10px;padding:10px 15px;width:500px">
<img src="../img/admin/error2.png" style="margin:-4px 5px 0 0;vertical-align:middle">
'.$message.'
</div>';
echo '<a href="'.htmlentities($url).'" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(translate('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" />
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" />
</a>
<a href="index.php" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(translate('Take me out of here!')).'" style="height:40px" />
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('Take me out of here!')).'" style="height:40px" />
</a>
</body></html>';
die;

View File

@@ -41,7 +41,7 @@ echo '
<link type="text/css" rel="stylesheet" href="'._PS_CSS_DIR_.'jquery.cluetip.css" />
<link type="text/css" rel="stylesheet" href="themes/'.Context::getContext()->employee->bo_theme.'/css/admin.css" />
<link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/chosen/jquery.chosen.css" />
<title>PrestaShop&trade; - '.translate('Administration panel').'</title>
<title>PrestaShop&trade; - '.Translate::getAdminTranslation('Administration panel').'</title>
<script type="text/javascript">
var helpboxes = '.Configuration::get('PS_HELPBOX').';
var roundMode = '.Configuration::get('PS_PRICE_ROUND_MODE').';
@@ -78,7 +78,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.order, function(property, value) {
html += "<li>'.translate('A new order has been made on your shop.').'<br />'.translate('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.translate('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.translate('Click here to see that order').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new order has been made on your shop.').'<br />'.Translate::getAdminTranslation('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.Translate::getAdminTranslation('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.Translate::getAdminTranslation('Click here to see that order').'</a></li>";
});
if (html != "")
@@ -99,7 +99,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.customer, function(property, value) {
html += "<li>'.translate('A new customer registered on your shop.').'<br />'.translate('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.translate('Click here to see that customer').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new customer registered on your shop.').'<br />'.Translate::getAdminTranslation('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.Translate::getAdminTranslation('Click here to see that customer').'</a></li>";
});
if (html != "")
{
@@ -121,7 +121,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.customer_message, function(property, value) {
html += "<li>'.translate('A new message posted on your shop.').'<br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.translate('Click here to see that message').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new message posted on your shop.').'<br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.Translate::getAdminTranslation('Click here to see that message').'</a></li>";
});
if (html != "")
@@ -149,14 +149,14 @@ echo '
if (Shop::isFeatureActive())
{
if (Shop::getContext() == Shop::CONTEXT_ALL)
$youEditFieldFor = translate('A modification of this field will be applied for all shops');
$youEditFieldFor = Translate::getAdminTranslation('A modification of this field will be applied for all shops');
elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>');
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>');
}
else
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo 'hints.html(hints.html()+\'<br /><span class="red">'.addslashes($youEditFieldFor).'</span>\');';
}
@@ -202,10 +202,10 @@ echo ' var html = "";
{
echo '<div id="orders_notif" class="notifs"><span id="orders_notif_number_wrapper" class="number_wrapper"><span id="orders_notif_value">0</span></span>
<div id="orders_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last orders').'</h3>
<p class="no_notifs">'.translate('No new orders has been made on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last orders').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new orders has been made on your shop').'</p>
<ul id="list_orders_notif"></ul>
<p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.translate('Show all orders').'</a></p>
<p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.Translate::getAdminTranslation('Show all orders').'</a></p>
</div>
</div>';
}
@@ -213,10 +213,10 @@ echo ' var html = "";
{
echo '<div id="customers_notif" class="notifs notifs_alternate"><span id="customers_notif_number_wrapper" class="number_wrapper"><span id="customers_notif_value">0</span></span>
<div id="customers_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last customers').'</h3>
<p class="no_notifs">'.translate('No new customers registered on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last customers').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new customers registered on your shop').'</p>
<ul id="list_customers_notif"></ul>
<p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.translate('Show all customers').'</a></p>
<p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.Translate::getAdminTranslation('Show all customers').'</a></p>
</div>
</div>';
}
@@ -224,21 +224,21 @@ echo ' var html = "";
{
echo '<div id="customer_messages_notif" class="notifs"><span id="customer_messages_notif_number_wrapper" class="number_wrapper"><span id="customer_messages_notif_value">0</span></span>
<div id="customer_messages_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last messages').'</h3>
<p class="no_notifs">'.translate('No new messages posted on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last messages').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new messages posted on your shop').'</p>
<ul id="list_customer_messages_notif"></ul>
<p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.translate('Show all messages').'</a></p>
<p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.Translate::getAdminTranslation('Show all messages').'</a></p>
</div>
</div>';
}
echo '</div><span id="employee_links">
<a href="index.php?controller=AdminEmployees&id_employee='.(int)Context::getContext()->employee->id.'&updateemployee&token='.Tools::getAdminTokenLite('AdminEmployees').'" class="employee">'.translate('My preferences').'</a>
<a href="index.php?controller=AdminEmployees&id_employee='.(int)Context::getContext()->employee->id.'&updateemployee&token='.Tools::getAdminTokenLite('AdminEmployees').'" class="employee">'.Translate::getAdminTranslation('My preferences').'</a>
<span class="separator"></span>
<span class="employee_name">
'.Tools::substr(Context::getContext()->employee->firstname, 0, 1).'.&nbsp;'.htmlentities(Context::getContext()->employee->lastname, ENT_COMPAT, 'UTF-8').'
</span><span class="separator"></span><a href="index.php?logout" id="header_logout"><span>'.translate('logout').'</span></a><span class="separator"></span>';
</span><span class="separator"></span><a href="index.php?logout" id="header_logout"><span>'.Translate::getAdminTranslation('logout').'</span></a><span class="separator"></span>';
if (Context::getContext()->shop->getBaseURL())
echo '<a href="'.Context::getContext()->shop->getBaseURL().'" id="header_foaccess" target="_blank" title="'.translate('View my shop').'"><span>'.translate('View my shop').'</span></a>';
echo '<a href="'.Context::getContext()->shop->getBaseURL().'" id="header_foaccess" target="_blank" title="'.Translate::getAdminTranslation('View my shop').'"><span>'.Translate::getAdminTranslation('View my shop').'</span></a>';
echo '</span>
<div id="header_search">
<form method="post" action="index.php?controller=AdminSearch&token='.Tools::getAdminTokenLite('AdminSearch').'">
@@ -246,15 +246,15 @@ echo ' var html = "";
value="'.Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))).'"
/>
<select name="bo_search_type" id="bo_search_type">
<option value="0">'.translate('everywhere').'</option>
<option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.translate('catalog').'</option>
<option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.translate('customers').'</option>
<option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.translate('ip address').'</option>
<option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.translate('orders').'</option>
<option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.translate('invoices').'</option>
<option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.translate('carts').'</option>
<option value="0">'.Translate::getAdminTranslation('everywhere').'</option>
<option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('catalog').'</option>
<option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('customers').'</option>
<option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('ip address').'</option>
<option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('orders').'</option>
<option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('invoices').'</option>
<option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('carts').'</option>
</select>
<input type="submit" id="bo_search_submit" class="button" value="'.translate('Search').'"/>
<input type="submit" id="bo_search_submit" class="button" value="'.Translate::getAdminTranslation('Search').'"/>
</form>
</div>
<div id="header_quick">
@@ -268,7 +268,7 @@ echo ' var html = "";
}
</script>
<select onchange="quickSelect(this);" id="quick_select">
<option value="0">'.translate('Quick Access').'</option>';
<option value="0">'.Translate::getAdminTranslation('Quick Access').'</option>';
foreach (QuickAccess::getQuickAccesses(Context::getContext()->language->id) AS $quick)
{
preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $adminTab);
@@ -333,8 +333,8 @@ echo '
<div id="main">
<div id="content">'
.(file_exists(_PS_ADMIN_DIR_.'/../install') ? '<div style="background-color: #FFEBCC;border: 1px solid #F90;line-height: 20px;margin: 0px 0px 10px;padding: 10px 20px;">'
.translate('For security reasons, you must also:').' '.
translate('delete the /install folder').
.Translate::getAdminTranslation('For security reasons, you must also:').' '.
Translate::getAdminTranslation('delete the /install folder').
'</div>' : '').'
';
if(defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
@@ -343,7 +343,7 @@ echo '
if (Shop::isFeatureActive() && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
{
echo '<div class="multishop_toolbar">
<span class="text_multishop">'.translate('Multistore configuration for').'</span>'.
<span class="text_multishop">'.Translate::getAdminTranslation('Multistore configuration for').'</span>'.
Helper::renderShopList();
echo '</div>';
}

View File

@@ -23,4 +23,5 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Location: index.php?controller=AdminLogin');

View File

@@ -959,7 +959,7 @@ class AdminTranslationsControllerCore extends AdminController
if ($type_file == 'php')
$regex = '/this->l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
else if ($type_file == 'specific')
$regex = '/translate\(\''._PS_TRANS_PATTERN_.'\'\)/U';
$regex = '/Translate::getAdminTranslation\(\''._PS_TRANS_PATTERN_.'\'\)/U';
else
$regex = '/\{l\s*s\s*=\''._PS_TRANS_PATTERN_.'\'(\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?\s*\}/U';
break;