diff --git a/core/lib/Thelia/Action/Lang.php b/core/lib/Thelia/Action/Lang.php index 059b685c9..b44c1b6b3 100644 --- a/core/lib/Thelia/Action/Lang.php +++ b/core/lib/Thelia/Action/Lang.php @@ -41,6 +41,9 @@ class Lang extends BaseAction implements EventSubscriberInterface ->setCode($event->getCode()) ->setDateFormat($event->getDateFormat()) ->setTimeFormat($event->getTimeFormat()) + ->setDecimalSeparator($event->getDecimalSeparator()) + ->setThousandsSeparator($event->getThousandsSeparator()) + ->setDecimals($event->getDecimals()) ->save(); $event->setLang($lang); @@ -69,6 +72,9 @@ class Lang extends BaseAction implements EventSubscriberInterface ->setLocale($event->getLocale()) ->setDateFormat($event->getDateFormat()) ->setTimeFormat($event->getTimeFormat()) + ->setDecimalSeparator($event->getDecimalSeparator()) + ->setThousandsSeparator($event->getThousandsSeparator()) + ->setDecimals($event->getDecimals()) ->save(); $event->setLang($lang); diff --git a/core/lib/Thelia/Controller/Admin/LangController.php b/core/lib/Thelia/Controller/Admin/LangController.php index 2a7a1004c..a3957b6e0 100644 --- a/core/lib/Thelia/Controller/Admin/LangController.php +++ b/core/lib/Thelia/Controller/Admin/LangController.php @@ -74,7 +74,10 @@ class LangController extends BaseAdminController 'code' => $lang->getCode(), 'locale' => $lang->getLocale(), 'date_format' => $lang->getDateFormat(), - 'time_format' => $lang->getTimeFormat() + 'time_format' => $lang->getTimeFormat(), + 'decimal_separator' => $lang->getDecimalSeparator(), + 'thousands_separator' => $lang->getThousandsSeparator(), + 'decimals' => $lang->getDecimals(), )); $this->getParserContext()->addForm($langForm); @@ -124,6 +127,9 @@ class LangController extends BaseAdminController ->setLocale($form->get('locale')->getData()) ->setDateFormat($form->get('date_format')->getData()) ->setTimeFormat($form->get('time_format')->getData()) + ->setDecimalSeparator($form->get('decimal_separator')->getData()) + ->setThousandsSeparator($form->get('thousands_separator')->getData()) + ->setDecimals($form->get('decimals')->getData()) ; } diff --git a/core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php b/core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php index f32121a11..0b0c35bdc 100644 --- a/core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php @@ -24,6 +24,9 @@ class LangCreateEvent extends LangEvent protected $locale; protected $date_format; protected $time_format; + protected $decimal_separator; + protected $thousands_separator; + protected $decimals; /** * @param mixed $code @@ -125,4 +128,60 @@ class LangCreateEvent extends LangEvent return $this->title; } + /** + * @param mixed $decimal_separator + */ + public function setDecimalSeparator($decimal_separator) + { + $this->decimal_separator = $decimal_separator; + + return $this; + } + + /** + * @return mixed + */ + public function getDecimalSeparator() + { + return $this->decimal_separator; + } + + /** + * @param mixed $decimals + */ + public function setDecimals($decimals) + { + $this->decimals = $decimals; + + return $this; + } + + /** + * @return mixed + */ + public function getDecimals() + { + return $this->decimals; + } + + /** + * @param mixed $thousands_separator + */ + public function setThousandsSeparator($thousands_separator) + { + $this->thousands_separator = $thousands_separator; + + return $this; + } + + /** + * @return mixed + */ + public function getThousandsSeparator() + { + return $this->thousands_separator; + } + + + } diff --git a/core/lib/Thelia/Form/Lang/LangCreateForm.php b/core/lib/Thelia/Form/Lang/LangCreateForm.php index ee1fd47f9..3ee88f779 100644 --- a/core/lib/Thelia/Form/Lang/LangCreateForm.php +++ b/core/lib/Thelia/Form/Lang/LangCreateForm.php @@ -91,6 +91,33 @@ class LangCreateForm extends BaseForm 'for' => 'time_lang' ) )) + ->add('decimal_separator', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('decimal separator'), + 'label_attr' => array( + 'for' => 'decimal_separator' + ) + )) + ->add('thousands_separator', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('thousands separator'), + 'label_attr' => array( + 'for' => 'thousands_separator' + ) + )) + ->add('decimals', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Sets the number of decimal points'), + 'label_attr' => array( + 'for' => 'decimals' + ) + )) ; } diff --git a/core/lib/Thelia/Model/Lang.php b/core/lib/Thelia/Model/Lang.php index a6a138a65..a0baa80c2 100644 --- a/core/lib/Thelia/Model/Lang.php +++ b/core/lib/Thelia/Model/Lang.php @@ -122,4 +122,10 @@ class Lang extends BaseLang $this->dispatchEvent(TheliaEvents::AFTER_DELETELANG, new LangEvent($this)); } + public function preSave(ConnectionInterface $con = null) + { + $this->setDatetimeFormat(sprintf("%s %s", $this->getDateFormat(), $this->getTimeFormat())); + + return true; + } } diff --git a/core/lib/Thelia/Tests/Action/LangTest.php b/core/lib/Thelia/Tests/Action/LangTest.php index 33ad1b63e..e4fc50e71 100644 --- a/core/lib/Thelia/Tests/Action/LangTest.php +++ b/core/lib/Thelia/Tests/Action/LangTest.php @@ -55,6 +55,9 @@ class LangTest extends \PHPUnit_Framework_TestCase ->setCode('TES') ->setDateFormat('Y-m-d') ->setTimeFormat('H:i:s') + ->setDecimalSeparator(".") + ->setThousandsSeparator(" ") + ->setDecimals("2") ->setDispatcher($this->dispatcher) ; @@ -72,6 +75,10 @@ class LangTest extends \PHPUnit_Framework_TestCase $this->assertEquals('TES', $createdLang->getCode()); $this->assertEquals('Y-m-d', $createdLang->getDateFormat()); $this->assertEquals('H:i:s', $createdLang->getTimeFormat()); + $this->assertEquals('.', $createdLang->getDecimalSeparator()); + $this->assertEquals(' ', $createdLang->getThousandsSeparator()); + $this->assertEquals('2', $createdLang->getDecimals()); + $this->assertEquals('Y-m-d H:i:s', $createdLang->getDatetimeFormat()); return $createdLang; } @@ -90,6 +97,9 @@ class LangTest extends \PHPUnit_Framework_TestCase ->setCode('TEST') ->setDateFormat('d-m-Y') ->setTimeFormat('H-i-s') + ->setDecimalSeparator(",") + ->setThousandsSeparator(".") + ->setDecimals("1") ->setDispatcher($this->dispatcher) ; @@ -105,6 +115,10 @@ class LangTest extends \PHPUnit_Framework_TestCase $this->assertEquals('test update', $updatedLang->getTitle()); $this->assertEquals('d-m-Y', $updatedLang->getDateFormat()); $this->assertEquals('H-i-s', $updatedLang->getTimeFormat()); + $this->assertEquals(',', $updatedLang->getDecimalSeparator()); + $this->assertEquals('.', $updatedLang->getThousandsSeparator()); + $this->assertEquals('1', $updatedLang->getDecimals()); + $this->assertEquals('d-m-Y H-i-s', $updatedLang->getDatetimeFormat()); return $updatedLang; } diff --git a/templates/backOffice/default/ajax/language-update-modal.html b/templates/backOffice/default/ajax/language-update-modal.html index f23e6d552..8727e6911 100644 --- a/templates/backOffice/default/ajax/language-update-modal.html +++ b/templates/backOffice/default/ajax/language-update-modal.html @@ -47,6 +47,27 @@ {intl l='The syntax used is identical to the PHP date() function'} {/form_field} + {form_field form=$form field='decimal_separator'} +
+ + + {intl l='Sets the separator for the decimal point'} +
+ {/form_field} + {form_field form=$form field='thousands_separator'} +
+ + + {intl l='Sets the thousands separator.'} +
+ {/form_field} + {form_field form=$form field='decimals'} +
+ + + {intl l='Sets the number of decimal points'} +
+ {/form_field} diff --git a/templates/backOffice/default/assets/img/flags/cz.png b/templates/backOffice/default/assets/img/flags/cs.png similarity index 100% rename from templates/backOffice/default/assets/img/flags/cz.png rename to templates/backOffice/default/assets/img/flags/cs.png diff --git a/templates/backOffice/default/languages.html b/templates/backOffice/default/languages.html index 3054db1c0..5e5c21bec 100644 --- a/templates/backOffice/default/languages.html +++ b/templates/backOffice/default/languages.html @@ -47,8 +47,6 @@ {intl l="Language name"} {intl l="ISO 639 Code"} {intl l="Locale"} - {intl l="date form"} - {intl l="time form"} {intl l="Default"} {intl l="Actions"} @@ -60,8 +58,6 @@ {$TITLE} {$CODE} {$LOCALE} - {$DATE_FORMAT} - {$TIME_FORMAT}
@@ -210,6 +206,27 @@ {intl l='The syntax used is identical to the PHP date() function'}
{/form_field} + {form_field form=$form field='decimal_separator'} +
+ + + {intl l='Sets the separator for the decimal point'} +
+ {/form_field} + {form_field form=$form field='thousands_separator'} +
+ + + {intl l='Sets the thousands separator.'} +
+ {/form_field} + {form_field form=$form field='decimals'} +
+ + + {intl l='Sets the number of decimal points'} +
+ {/form_field} {module_include location='language_create_form'}