diff --git a/composer.json b/composer.json index 0a54e82cc..d644f6ce6 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,8 @@ "imagine/imagine": "*", "zendframework/zend-progressbar": "^2.5", "zendframework/zend-math": "^3.0", - "zendframework/zend-captcha": "^2.7" + "zendframework/zend-captcha": "^2.7", + "zendframework/zend-i18n-resources": "^2.5" }, "require-dev": { "cbleek/pecl-solr-hint": "dev-master", diff --git a/composer.lock b/composer.lock index 6f547b685..b4230c15d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "cb3156f21d71697e6596a544fe076a2d", + "content-hash": "0d644d144ddd601f3254482aba5fe0db", "packages": [ { "name": "container-interop/container-interop", @@ -2615,6 +2615,41 @@ ], "time": "2017-05-17T17:00:12+00:00" }, + { + "name": "zendframework/zend-i18n-resources", + "version": "2.5.2", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-i18n-resources.git", + "reference": "fe53e1c96654c4fc89975d14ed13ccbce6c08179" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-i18n-resources/zipball/fe53e1c96654c4fc89975d14ed13ccbce6c08179", + "reference": "fe53e1c96654c4fc89975d14ed13ccbce6c08179", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/Resources.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Provides validator translations for zend-i18n's Translator", + "keywords": [ + "resources", + "translations", + "zf2" + ], + "time": "2015-07-22T17:21:40+00:00" + }, { "name": "zendframework/zend-inputfilter", "version": "2.8.0", diff --git a/module/Core/config/module.config.php b/module/Core/config/module.config.php index ba5698460..861439e24 100644 --- a/module/Core/config/module.config.php +++ b/module/Core/config/module.config.php @@ -13,6 +13,7 @@ */ namespace Core; +use Zend\I18n\Translator\Resources; use Zend\ServiceManager\Factory\InvokableFactory; $doctrineConfig = include __DIR__ . '/doctrine.config.php'; @@ -204,7 +205,6 @@ 'Core/Listener/DeferredListenerAggregate' => [\Core\Listener\DeferredListenerAggregate::class,'factory'], 'Core/Listener/CreatePaginator' => 'Core\Listener\CreatePaginatorListener::factory', 'Core/Locale' => 'Core\I18n\LocaleFactory', - 'mvctranslator' => \Zend\Mvc\I18n\TranslatorFactory::class, \Core\Listener\AjaxRouteListener::class => \Core\Factory\Listener\AjaxRouteListenerFactory::class, \Core\Listener\DeleteImageSetListener::class => \Core\Factory\Listener\DeleteImageSetListenerFactory::class, 'Imagine' => \Core\Factory\Service\ImagineFactory::class, @@ -217,7 +217,8 @@ 'aliases' => array( 'forms' => 'FormElementManager', 'repositories' => 'Core/RepositoryService', - 'translator' => 'mvctranslator', + 'mvctranslator' => 'MvcTranslator', + 'translator' => 'MvcTranslator', ), 'shared' => array( 'Core/Listener/DeferredListenerAggregate' => false, @@ -235,13 +236,13 @@ ], [ 'type' => 'phparray', - 'base_dir' => __DIR__ . '/../language', - 'pattern' => 'Zend_Validate.%s.php', + 'base_dir' => Resources::getBasePath(), + 'pattern' => Resources::getPatternForValidator(), ], [ 'type' => 'phparray', - 'base_dir' => __DIR__ . '/../language', - 'pattern' => 'Zend_Captcha.%s.php', + 'base_dir' => Resources::getBasePath(), + 'pattern' => Resources::getPatternForCaptcha(), ] ), ), diff --git a/module/Core/src/Core/Listener/LanguageRouteListener.php b/module/Core/src/Core/Listener/LanguageRouteListener.php index 9099636ab..70ce4578f 100644 --- a/module/Core/src/Core/Listener/LanguageRouteListener.php +++ b/module/Core/src/Core/Listener/LanguageRouteListener.php @@ -224,6 +224,7 @@ protected function setLocale(MvcEvent $e, $lang) Locale::setDefault($locale); $translator->setLocale($locale); + $translator->setFallbackLocale(substr($locale, 0, 2)); $routeMatch = $e->getRouteMatch(); if ($routeMatch && $routeMatch->getParam('lang') === null) { $routeMatch->setParam('lang', $lang);