Translation : Ordering existing translations by keys. This should ease the merge process when conflicts occur

Fixed issue #123. Introduced NumberFormat::formatStandardNumber()

Adding translation for Backoffice

Adding translation for Backoffice

fix close #131

fix updatePositionDownTest

Translation : Ordering existing translations by keys. This should ease the merge process when conflicts occur

Translation : Ordering existing translations by keys, This should ease the merge process when conflicts occur

Translation : Ordering existing translations by keys, This should ease the merge process when conflicts occur
This commit is contained in:
Franck Allimant
2013-12-05 18:08:36 +01:00
committed by gmorel
parent 5857c07ef0
commit bf64cd117e
22 changed files with 350 additions and 222 deletions

View File

@@ -41,6 +41,8 @@ class HomeController extends BaseAdminController
public function loadStatsAjaxAction()
{
if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response;
$data = new \stdClass();
$data->title = "Stats on " . $this->getRequest()->query->get('month', date('m')) . "/" . $this->getRequest()->query->get('year', date('Y'));

View File

@@ -1201,10 +1201,10 @@ class ProductController extends AbstractCrudController
}
return new JsonResponse(array(
'price_with_tax' => NumberFormat::getInstance($this->getRequest())->format($price_with_tax, null, '.'),
'price_without_tax' => NumberFormat::getInstance($this->getRequest())->format($price_without_tax, null, '.'),
'sale_price_with_tax' => NumberFormat::getInstance($this->getRequest())->format($sale_price_with_tax, null, '.'),
'sale_price_without_tax' => NumberFormat::getInstance($this->getRequest())->format($sale_price_without_tax, null, '.')
'price_with_tax' => NumberFormat::getInstance($this->getRequest())->formatStandardNumber($price_with_tax),
'price_without_tax' => NumberFormat::getInstance($this->getRequest())->formatStandardNumber($price_without_tax),
'sale_price_with_tax' => NumberFormat::getInstance($this->getRequest())->formatStandardNumber($sale_price_with_tax),
'sale_price_without_tax' => NumberFormat::getInstance($this->getRequest())->formatStandardNumber($sale_price_without_tax)
));
}
@@ -1236,7 +1236,8 @@ class ProductController extends AbstractCrudController
if ($convert != 0) {
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
}
// Format the number using '.', to perform further calculation
return NumberFormat::getInstance($this->getRequest())->format($return_price, null, '.');
return NumberFormat::getInstance($this->getRequest())->formatStandardNumber($return_price);
}
}

View File

@@ -94,6 +94,10 @@ class TranslationsController extends BaseAdminController
case 'pf' :
$template = new TemplateDefinition($item_id, TemplateDefinition::PDF);
break;
case 'ma' :
$template = new TemplateDefinition($item_id, TemplateDefinition::EMAIL);
break;
}
if ($template) {

View File

@@ -38,20 +38,6 @@ final class TheliaEvents
*/
const BOOT = "thelia.boot";
/**
* ACTION event
*
* Sent if no action are already present in Thelia action process ( see Thelia\Routing\Matcher\ActionMatcher)
*/
const ACTION = "thelia.action";
/**
* INCLUDE event
*
* Sent before starting thelia inclusion
*/
const INCLUSION = "thelia.include";
/**
* Sent before the logout of the customer.
*/

View File

@@ -181,10 +181,8 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
break;
}
}
echo "s=".$search->toString();
return $search;
}
public function parseResults(LoopResult $loopResult)

View File

@@ -64,7 +64,8 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
new Type\EnumListType(array(
'front-office',
'back-office',
'pdf'
'pdf',
'email'
))
)
)
@@ -80,6 +81,8 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
$templateType = TemplateDefinition::BACK_OFFICE;
else if ($type == 'pdf')
$templateType = TemplateDefinition::PDF;
else if ($type == 'email')
$templateType = TemplateDefinition::EMAIL;
return TemplateHelper::getInstance()->getList($templateType);
}

View File

@@ -240,20 +240,18 @@ class TemplateHelper
fwrite($fp, '<' . "?php\n\n");
fwrite($fp, "return array(\n");
$idx = 0;
// Sort keys alphabetically while keeping index
asort($texts);
foreach($texts as $text)
{
foreach ($texts as $key => $text) {
// Write only defined (not empty) translations
if (! empty($translations[$idx])) {
if (! empty($translations[$key])) {
$text = str_replace("'", "\'", $text);
$translation = str_replace("'", "\'", $translations[$idx]);
$translation = str_replace("'", "\'", $translations[$key]);
fwrite($fp, sprintf("\t'%s' => '%s',\n", $text, $translation));
}
$idx++;
}
fwrite($fp, ");\n");

View File

@@ -115,6 +115,8 @@ class Category extends BaseCategory
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
}
}

View File

@@ -148,6 +148,8 @@ class Content extends BaseContent
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this));
}
}

View File

@@ -100,6 +100,8 @@ class Folder extends BaseFolder
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this));
}
}

View File

@@ -263,12 +263,8 @@ class Product extends BaseProduct
*/
public function postDelete(ConnectionInterface $con = null)
{
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
}
}

View File

@@ -29,6 +29,7 @@ use Thelia\Exception\UrlRewritingException;
use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\RewritingUrl;
use Thelia\Tools\URL;
use Thelia\Model\ConfigQuery;
/**
* A trait for managing Rewritten URLs from model classes
*/
@@ -136,6 +137,18 @@ trait UrlRewritingTrait {
return $url;
}
/**
* Mark the current URL as obseolete
*/
public function markRewritenUrlObsolete() {
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
}
/**
* Set the rewritten URL for the given locale
*

View File

@@ -162,14 +162,19 @@ class FolderTest extends BaseAction
public function testUpdatePositionDown()
{
$folder = FolderQuery::create()
->filterByPosition(1)
$nextFolder = FolderQuery::create()
->filterByPosition(2)
->findOne();
if (null === $folder) {
if (null === $nextFolder) {
$this->fail('use fixtures before launching test, there is no folder in database');
}
$folder = FolderQuery::create()
->filterByPosition(1)
->filterByParent($nextFolder->getParent())
->findOne();
$newPosition = $folder->getPosition()+1;
$event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_DOWN);

View File

@@ -39,6 +39,22 @@ class NumberFormat
return new NumberFormat($request);
}
/**
* Get a standard number, with '.' as decimal point and no thousands separator
* so that this number can be used to perform calculations.
*
* @param float $number the number
* @param string $decimals number of decimal figures
*/
public function formatStandardNumber($number, $decimals = null) {
$lang = $this->request->getSession()->getLang();
if ($decimals == null) $decimals = $lang->getDecimals();
return number_format($number, $decimals, '.', '');
}
public function format($number, $decimals = null, $decPoint = null, $thousandsSep = null)
{
$lang = $this->request->getSession()->getLang();