Skip to content

Commit dca9cb1

Browse files
order statuses are now created with domain defined locales (#3856)
1 parent 23240c4 commit dca9cb1

File tree

3 files changed

+53
-23
lines changed

3 files changed

+53
-23
lines changed

src/Migrations/Version20180603135341.php

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
namespace Shopsys\FrameworkBundle\Migrations;
66

77
use Doctrine\DBAL\Schema\Schema;
8+
use Shopsys\FrameworkBundle\Component\Translation\Translator;
89
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration;
10+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
911

10-
class Version20180603135341 extends AbstractMigration
12+
class Version20180603135341 extends AbstractMigration implements ContainerAwareInterface
1113
{
14+
use MultidomainMigrationTrait;
15+
1216
/**
1317
* @param \Doctrine\DBAL\Schema\Schema $schema
1418
*/
@@ -19,43 +23,51 @@ public function up(Schema $schema): void
1923
if ($orderStatusesCount > 0) {
2024
return;
2125
}
22-
$this->createOrderStatusWithEnglishAndCzechTranslations(1, 1, 'New', 'Nová');
23-
$this->createOrderStatusWithEnglishAndCzechTranslations(2, 2, 'In Progress', 'Vyřizuje se');
24-
$this->createOrderStatusWithEnglishAndCzechTranslations(3, 3, 'Done', 'Vyřízena');
25-
$this->createOrderStatusWithEnglishAndCzechTranslations(4, 4, 'Canceled', 'Stornována');
26+
27+
$this->createOrderStatus(1, 1);
28+
$this->createOrderStatus(2, 2);
29+
$this->createOrderStatus(3, 3);
30+
$this->createOrderStatus(4, 4);
31+
32+
33+
foreach ($this->getAllLocales() as $locale) {
34+
$this->createOrderStatusTranslations(1, t('New', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale), $locale);
35+
$this->createOrderStatusTranslations(2, t('In Progress', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale), $locale);
36+
$this->createOrderStatusTranslations(3, t('Done', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale), $locale);
37+
$this->createOrderStatusTranslations(4, t('Canceled', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale), $locale);
38+
}
39+
2640
$this->sql('ALTER SEQUENCE order_statuses_id_seq RESTART WITH 5');
2741
}
2842

2943
/**
3044
* @param int $orderStatusId
3145
* @param int $orderStatusType
32-
* @param string $orderStatusEnglishName
33-
* @param string $orderStatusCzechName
3446
*/
35-
private function createOrderStatusWithEnglishAndCzechTranslations(
36-
$orderStatusId,
37-
$orderStatusType,
38-
$orderStatusEnglishName,
39-
$orderStatusCzechName,
40-
) {
47+
private function createOrderStatus(int $orderStatusId, int $orderStatusType): void
48+
{
4149
$this->sql('INSERT INTO order_statuses (id, type) VALUES (:id, :type)', [
4250
'id' => $orderStatusId,
4351
'type' => $orderStatusType,
4452
]);
53+
}
54+
55+
/**
56+
* @param int $orderStatusId
57+
* @param string $orderStatusTranslatedName
58+
* @param string $locale
59+
*/
60+
private function createOrderStatusTranslations(
61+
int $orderStatusId,
62+
string $orderStatusTranslatedName,
63+
string $locale,
64+
): void {
4565
$this->sql(
4666
'INSERT INTO order_status_translations (translatable_id, name, locale) VALUES (:translatableId, :name, :locale)',
4767
[
4868
'translatableId' => $orderStatusId,
49-
'name' => $orderStatusEnglishName,
50-
'locale' => 'en',
51-
],
52-
);
53-
$this->sql(
54-
'INSERT INTO order_status_translations (translatable_id, name, locale) VALUES (:translatableId, :name, :locale)',
55-
[
56-
'translatableId' => $orderStatusId,
57-
'name' => $orderStatusCzechName,
58-
'locale' => 'cs',
69+
'name' => $orderStatusTranslatedName,
70+
'locale' => $locale,
5971
],
6072
);
6173
}

src/Resources/translations/messages.cs.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ msgstr "Vypočtená cena vč. DPH"
619619
msgid "Cancel"
620620
msgstr "Zrušit"
621621

622+
msgid "Canceled"
623+
msgstr "Stornována"
624+
622625
msgid "Cannot read file."
623626
msgstr "Soubor nelze načíst."
624627

@@ -1510,6 +1513,9 @@ msgstr "Filtr domén"
15101513
msgid "Domain name"
15111514
msgstr "Název domény"
15121515

1516+
msgid "Done"
1517+
msgstr "Vyřízena"
1518+
15131519
msgid "Download"
15141520
msgstr "Stáhnout"
15151521

@@ -2329,6 +2335,9 @@ msgstr "Nahrát CSV"
23292335
msgid "Import price list"
23302336
msgstr "Nahrát ceník"
23312337

2338+
msgid "In Progress"
2339+
msgstr "Vyřizuje se"
2340+
23322341
msgid "In a particular domain tab it is not possible to adjust the order and plunge of categories. Please go to the category detail or to overview of categories of all domains"
23332342
msgstr "Na záložce konkrétní domény není možné upravovat pořadí a zanoření kategorií. Prosím přejděte na kartu kategorie nebo na přehled kategorií všech domén."
23342343

src/Resources/translations/messages.en.po

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ msgstr ""
619619
msgid "Cancel"
620620
msgstr ""
621621

622+
msgid "Canceled"
623+
msgstr ""
624+
622625
msgid "Cannot read file."
623626
msgstr ""
624627

@@ -1510,6 +1513,9 @@ msgstr ""
15101513
msgid "Domain name"
15111514
msgstr ""
15121515

1516+
msgid "Done"
1517+
msgstr ""
1518+
15131519
msgid "Download"
15141520
msgstr ""
15151521

@@ -2329,6 +2335,9 @@ msgstr ""
23292335
msgid "Import price list"
23302336
msgstr ""
23312337

2338+
msgid "In Progress"
2339+
msgstr ""
2340+
23322341
msgid "In a particular domain tab it is not possible to adjust the order and plunge of categories. Please go to the category detail or to overview of categories of all domains"
23332342
msgstr ""
23342343

0 commit comments

Comments
 (0)