From 5458c74ccd51610c7fbf9f1eadd1ab00fbd101f1 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 13:47:49 +0300 Subject: [PATCH] Move translations from utils bundle to utils lib. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 27 ++++++++++++++------ Resources/translations/messages.ar.yaml | 9 ------- Resources/translations/messages.en.yaml | 11 -------- Resources/translations/messages.fr.yaml | 9 ------- Resources/translations/messages.ru.yaml | 11 -------- Resources/translations/messages.zh.yaml | 9 ------- Resources/translations/validators.ar.yaml | 2 -- Resources/translations/validators.en.yaml | 2 -- Resources/translations/validators.fr.yaml | 2 -- Resources/translations/validators.ru.yaml | 2 -- Resources/translations/validators.zh.yaml | 2 -- 12 files changed, 21 insertions(+), 67 deletions(-) delete mode 100644 Resources/translations/messages.ar.yaml delete mode 100644 Resources/translations/messages.en.yaml delete mode 100644 Resources/translations/messages.fr.yaml delete mode 100644 Resources/translations/messages.ru.yaml delete mode 100644 Resources/translations/messages.zh.yaml delete mode 100644 Resources/translations/validators.ar.yaml delete mode 100644 Resources/translations/validators.en.yaml delete mode 100644 Resources/translations/validators.fr.yaml delete mode 100644 Resources/translations/validators.ru.yaml delete mode 100644 Resources/translations/validators.zh.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 38971f1..76cfa25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,3 +90,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Move price formatter to utils lib. - Move macros template to utils lib. + +- Move translations to utils lib. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 3411e57..59c391c 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -114,14 +114,25 @@ public function prepend(ContainerBuilder $container): void 'stof_doctrine_extensions', ]); - if ($container->hasExtension('twig')) { - $path = sprintf('%s/../Resources/views', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); - - $container->prependExtensionConfig('twig', [ - 'paths' => [ - $path => 'DarvinUtils', - ], - ]); + if ($container->hasExtension('framework') || $container->hasExtension('twig')) { + $dir = sprintf('%s/../Resources', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); + + if ($container->hasExtension('framework')) { + $container->prependExtensionConfig('framework', [ + 'translator' => [ + 'paths' => [ + sprintf('%s/translations', $dir), + ], + ], + ]); + } + if ($container->hasExtension('twig')) { + $container->prependExtensionConfig('twig', [ + 'paths' => [ + sprintf('%s/views', $dir) => 'DarvinUtils', + ], + ]); + } } } diff --git a/Resources/translations/messages.ar.yaml b/Resources/translations/messages.ar.yaml deleted file mode 100644 index 7c9af5e..0000000 --- a/Resources/translations/messages.ar.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: 'غير محدد' - 'no': لا - 'yes': نعم -flash: - error: - form: 'شكل الأخطاء المكتشفة. اصلاحها وإعادة تشكيل' -price: - default: AED %price% diff --git a/Resources/translations/messages.en.yaml b/Resources/translations/messages.en.yaml deleted file mode 100644 index 3b22dc3..0000000 --- a/Resources/translations/messages.en.yaml +++ /dev/null @@ -1,11 +0,0 @@ -boolean: - indeterminate: Indeterminate - no: No - yes: Yes - -flash: - error: - form: Form Errors Detected. Fix Them and Resubmit Form - -price: - default: $%price% diff --git a/Resources/translations/messages.fr.yaml b/Resources/translations/messages.fr.yaml deleted file mode 100644 index 0a68160..0000000 --- a/Resources/translations/messages.fr.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: Indéterminée - 'no': 'Pas de' - 'yes': Oui -flash: - error: - form: 'Des Erreurs Détectées. Les corriger et de soumettre à nouveau le Formulaire' -price: - default: '%price% €' diff --git a/Resources/translations/messages.ru.yaml b/Resources/translations/messages.ru.yaml deleted file mode 100644 index cfe7ef7..0000000 --- a/Resources/translations/messages.ru.yaml +++ /dev/null @@ -1,11 +0,0 @@ -boolean: - indeterminate: Не определено - no: Нет - yes: Да - -flash: - error: - form: При обработке формы были обнаружены ошибки. Исправьте их и повторите отправку - -price: - default: '%price% руб.' diff --git a/Resources/translations/messages.zh.yaml b/Resources/translations/messages.zh.yaml deleted file mode 100644 index 5127d35..0000000 --- a/Resources/translations/messages.zh.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: 不确定 - 'no': 没有 - 'yes': 是的 -flash: - error: - form: '形成的错误检测。 解决这些问题,并重新提交形式' -price: - default: ¥%price% diff --git a/Resources/translations/validators.ar.yaml b/Resources/translations/validators.ar.yaml deleted file mode 100644 index d6f4979..0000000 --- a/Resources/translations/validators.ar.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 'هذه القيمة غير صالحة رقم الهاتف.' diff --git a/Resources/translations/validators.en.yaml b/Resources/translations/validators.en.yaml deleted file mode 100644 index 33ef3f7..0000000 --- a/Resources/translations/validators.en.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: This value is not valid phone number. diff --git a/Resources/translations/validators.fr.yaml b/Resources/translations/validators.fr.yaml deleted file mode 100644 index 98b4740..0000000 --- a/Resources/translations/validators.fr.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 'Cette valeur n''est pas valide, numéro de téléphone.' diff --git a/Resources/translations/validators.ru.yaml b/Resources/translations/validators.ru.yaml deleted file mode 100644 index a6fd19d..0000000 --- a/Resources/translations/validators.ru.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: Номер телефона указан в неверном формате. diff --git a/Resources/translations/validators.zh.yaml b/Resources/translations/validators.zh.yaml deleted file mode 100644 index d2272d1..0000000 --- a/Resources/translations/validators.zh.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 这种价值是不是有效的电话号码。