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
55c9c06b
Commit
55c9c06b
authored
May 25, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made translator.domains and translator.messages optional
parent
deaa987f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
doc/providers/translation.rst
doc/providers/translation.rst
+3
-3
src/Silex/Provider/TranslationServiceProvider.php
src/Silex/Provider/TranslationServiceProvider.php
+10
-5
No files found.
doc/providers/translation.rst
View file @
55c9c06b
...
@@ -7,10 +7,10 @@ application into different languages.
...
@@ -7,10 +7,10 @@ application into different languages.
Parameters
Parameters
----------
----------
* **translator.messages**
: A mapping of locales to message arrays. This
* **translator.messages**
(optional): A mapping of locales to message arrays.
parameter contains the translation data in all languages.
This
parameter contains the translation data in all languages.
* **translator.domains**: Same as above but stored by domains.
* **translator.domains**
(optional)
: Same as above but stored by domains.
* **locale** (optional): The locale for the translator. You will most likely
* **locale** (optional): The locale for the translator. You will most likely
want to set this based on some request parameter. Defaults to ``en``.
want to set this based on some request parameter. Defaults to ``en``.
...
...
src/Silex/Provider/TranslationServiceProvider.php
View file @
55c9c06b
...
@@ -35,13 +35,18 @@ class TranslationServiceProvider implements ServiceProviderInterface
...
@@ -35,13 +35,18 @@ class TranslationServiceProvider implements ServiceProviderInterface
}
}
$translator
->
addLoader
(
'array'
,
$app
[
'translator.loader'
]);
$translator
->
addLoader
(
'array'
,
$app
[
'translator.loader'
]);
foreach
(
$app
[
'translator.messages'
]
as
$locale
=>
$messages
)
{
$translator
->
addResource
(
'array'
,
$messages
,
$locale
);
if
(
isset
(
$app
[
'translator.messages'
]))
{
foreach
(
$app
[
'translator.messages'
]
as
$locale
=>
$messages
)
{
$translator
->
addResource
(
'array'
,
$messages
,
$locale
);
}
}
}
foreach
(
$app
[
'translator.domains'
]
as
$domain
=>
$data
)
{
if
(
isset
(
$app
[
'translator.domains'
]))
{
foreach
(
$data
as
$locale
=>
$messages
)
{
foreach
(
$app
[
'translator.domains'
]
as
$domain
=>
$data
)
{
$translator
->
addResource
(
'array'
,
$messages
,
$locale
,
$domain
);
foreach
(
$data
as
$locale
=>
$messages
)
{
$translator
->
addResource
(
'array'
,
$messages
,
$locale
,
$domain
);
}
}
}
}
}
...
...
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