diff --git a/README.md b/README.md index c099b8e..2f7c747 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,11 @@ $app = new Application(); //... $app->register(new Jenyak\I18nRouting\Provider\I18nRoutingServiceProvider()); $app['locale'] = 'en'; -$app['i18n_routing.locales'] = array('en', 'hu', 'ua'); +$app['i18n_routing.locales'] = array('en', 'eu', 'fr'); // You can translate patterns $app['translator.domains'] = array('routes' => array( - 'hu' => array('test_route' => '/teszt'), + 'fr' => array('test_route' => '/entsegu-bat'), )); // There's no need to put {_locale} in route pattern @@ -54,11 +54,11 @@ $app->get('/test', function () { ``` Matched URLs will be: -`/test` - url for default locale without prefix +`/en/test` - url for default locale without prefix -`/hu/teszt` - url with prefix and translated +`/eu/entsegu-bat` - url with prefix and translated -`/ua/test` - url with prefix +`/fr/test` - url with prefix # Disable I18n for a route ```php diff --git a/src/Jenyak/I18nRouting/I18nControllerCollection.php b/src/Jenyak/I18nRouting/I18nControllerCollection.php index 417da90..d3b6dbe 100644 --- a/src/Jenyak/I18nRouting/I18nControllerCollection.php +++ b/src/Jenyak/I18nRouting/I18nControllerCollection.php @@ -36,9 +36,7 @@ public function generateI18nPatterns($routeName, Route $route) $i18nPattern = $route->getPath(); } - if ($this->defaultLocale !== $locale) { - $i18nPattern = '/'.$locale.$i18nPattern; - } + $i18nPattern = '/'.$locale.$i18nPattern; $patterns[$i18nPattern][] = $locale; } diff --git a/tests/I18nRoutingServiceProviderTest.php b/tests/I18nRoutingServiceProviderTest.php index 97e7a33..a3c9931 100644 --- a/tests/I18nRoutingServiceProviderTest.php +++ b/tests/I18nRoutingServiceProviderTest.php @@ -34,7 +34,8 @@ public function testDefaultLocaleI18nRoutes() return 'ok'; })->bind('test'); - $this->assertEquals(200, $app->handle(Request::create('/test'))->getStatusCode()); + $this->assertEquals(404, $app->handle(Request::create('/test'))->getStatusCode()); + $this->assertEquals(200, $app->handle(Request::create('/en/test'))->getStatusCode()); } public function testDefaultLocaleWithPrefixI18nRoutes() @@ -45,7 +46,7 @@ public function testDefaultLocaleWithPrefixI18nRoutes() return 'ok'; }); - $this->assertEquals(404, $app->handle(Request::create('/en/'))->getStatusCode()); + $this->assertEquals(200, $app->handle(Request::create('/en/'))->getStatusCode()); } public function testNonDefaultLocaleI18nRoutes()