Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
38d505a0
Commit
38d505a0
authored
Jun 16, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made form and validator translations aware of the current locale
parent
9674ce90
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
7 deletions
+8
-7
doc/changelog.rst
doc/changelog.rst
+2
-0
src/Silex/Application.php
src/Silex/Application.php
+4
-3
src/Silex/Provider/FormServiceProvider.php
src/Silex/Provider/FormServiceProvider.php
+1
-1
src/Silex/Provider/TranslationServiceProvider.php
src/Silex/Provider/TranslationServiceProvider.php
+0
-2
src/Silex/Provider/ValidatorServiceProvider.php
src/Silex/Provider/ValidatorServiceProvider.php
+1
-1
No files found.
doc/changelog.rst
View file @
38d505a0
Changelog
Changelog
=========
=========
* **2012-06-16**: renamed ``request.default_locale`` to ``locale``
* **2012-06-16**: Removed the ``translator.loader`` service. See documentation
* **2012-06-16**: Removed the ``translator.loader`` service. See documentation
for how to use XLIFF or YAML-based translation files.
for how to use XLIFF or YAML-based translation files.
...
...
src/Silex/Application.php
View file @
38d505a0
...
@@ -85,7 +85,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -85,7 +85,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
return
$app
[
'url_matcher'
];
return
$app
[
'url_matcher'
];
});
});
$dispatcher
->
addSubscriber
(
new
RouterListener
(
$urlMatcher
,
$app
[
'logger'
]));
$dispatcher
->
addSubscriber
(
new
RouterListener
(
$urlMatcher
,
$app
[
'logger'
]));
$dispatcher
->
addSubscriber
(
new
LocaleListener
(
$app
[
'
request.default_
locale'
],
$urlMatcher
));
$dispatcher
->
addSubscriber
(
new
LocaleListener
(
$app
[
'locale'
],
$urlMatcher
));
return
$dispatcher
;
return
$dispatcher
;
});
});
...
@@ -147,8 +147,6 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -147,8 +147,6 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
}
}
});
});
$this
[
'request.default_locale'
]
=
'en'
;
$this
[
'request_error'
]
=
$this
->
protect
(
function
()
{
$this
[
'request_error'
]
=
$this
->
protect
(
function
()
{
throw
new
\RuntimeException
(
'Accessed request service outside of request scope. Try moving that call to a before handler or controller.'
);
throw
new
\RuntimeException
(
'Accessed request service outside of request scope. Try moving that call to a before handler or controller.'
);
});
});
...
@@ -159,6 +157,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -159,6 +157,7 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
$this
[
'request.https_port'
]
=
443
;
$this
[
'request.https_port'
]
=
443
;
$this
[
'debug'
]
=
false
;
$this
[
'debug'
]
=
false
;
$this
[
'charset'
]
=
'UTF-8'
;
$this
[
'charset'
]
=
'UTF-8'
;
$this
[
'locale'
]
=
'en'
;
}
}
/**
/**
...
@@ -537,6 +536,8 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -537,6 +536,8 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
*/
*/
public
function
onKernelRequest
(
GetResponseEvent
$event
)
public
function
onKernelRequest
(
GetResponseEvent
$event
)
{
{
$this
[
'locale'
]
=
$event
->
getRequest
()
->
getLocale
();
if
(
HttpKernelInterface
::
MASTER_REQUEST
===
$event
->
getRequestType
())
{
if
(
HttpKernelInterface
::
MASTER_REQUEST
===
$event
->
getRequestType
())
{
$this
->
beforeDispatched
=
true
;
$this
->
beforeDispatched
=
true
;
$this
[
'dispatcher'
]
->
dispatch
(
SilexEvents
::
BEFORE
,
$event
);
$this
[
'dispatcher'
]
->
dispatch
(
SilexEvents
::
BEFORE
,
$event
);
...
...
src/Silex/Provider/FormServiceProvider.php
View file @
38d505a0
...
@@ -42,7 +42,7 @@ class FormServiceProvider implements ServiceProviderInterface
...
@@ -42,7 +42,7 @@ class FormServiceProvider implements ServiceProviderInterface
if
(
isset
(
$app
[
'translator'
]))
{
if
(
isset
(
$app
[
'translator'
]))
{
$r
=
new
\ReflectionClass
(
'Symfony\Component\Form\Form'
);
$r
=
new
\ReflectionClass
(
'Symfony\Component\Form\Form'
);
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.
en.xlf'
,
'en'
,
'validators'
);
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.
'
.
$app
[
'locale'
]
.
'.xlf'
,
$app
[
'locale'
]
,
'validators'
);
}
}
}
}
...
...
src/Silex/Provider/TranslationServiceProvider.php
View file @
38d505a0
...
@@ -28,8 +28,6 @@ class TranslationServiceProvider implements ServiceProviderInterface
...
@@ -28,8 +28,6 @@ class TranslationServiceProvider implements ServiceProviderInterface
{
{
public
function
register
(
Application
$app
)
public
function
register
(
Application
$app
)
{
{
$app
[
'locale'
]
=
'en'
;
$app
[
'translator'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
$app
[
'translator'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
$translator
=
new
Translator
(
$app
[
'locale'
],
$app
[
'translator.message_selector'
]);
$translator
=
new
Translator
(
$app
[
'locale'
],
$app
[
'translator.message_selector'
]);
...
...
src/Silex/Provider/ValidatorServiceProvider.php
View file @
38d505a0
...
@@ -31,7 +31,7 @@ class ValidatorServiceProvider implements ServiceProviderInterface
...
@@ -31,7 +31,7 @@ class ValidatorServiceProvider implements ServiceProviderInterface
$app
[
'validator'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
$app
[
'validator'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
if
(
isset
(
$app
[
'translator'
]))
{
if
(
isset
(
$app
[
'translator'
]))
{
$r
=
new
\ReflectionClass
(
'Symfony\Component\Validator\Validator'
);
$r
=
new
\ReflectionClass
(
'Symfony\Component\Validator\Validator'
);
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.
en.xlf'
,
'en'
,
'validators'
);
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.
'
.
$app
[
'locale'
]
.
'.xlf'
,
$app
[
'locale'
]
,
'validators'
);
}
}
return
new
Validator
(
return
new
Validator
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment