Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
17ca07fd
Commit
17ca07fd
authored
Feb 01, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More consistent usage of MessageFormatter::tokenizePattern
parent
b21fd298
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
MessageFormatter.php
framework/i18n/MessageFormatter.php
+7
-7
No files found.
framework/i18n/MessageFormatter.php
View file @
17ca07fd
...
@@ -137,7 +137,7 @@ class MessageFormatter extends Component
...
@@ -137,7 +137,7 @@ class MessageFormatter extends Component
}
}
// replace named arguments
// replace named arguments
if
((
$tokens
=
$this
->
tokenizePattern
(
$pattern
))
===
false
)
{
if
((
$tokens
=
self
::
tokenizePattern
(
$pattern
))
===
false
)
{
$this
->
_errorCode
=
-
1
;
$this
->
_errorCode
=
-
1
;
$this
->
_errorMessage
=
"Message pattern is invalid."
;
$this
->
_errorMessage
=
"Message pattern is invalid."
;
return
false
;
return
false
;
...
@@ -187,7 +187,7 @@ class MessageFormatter extends Component
...
@@ -187,7 +187,7 @@ class MessageFormatter extends Component
*/
*/
private
function
replaceNamedArguments
(
$pattern
,
$givenParams
,
&
$resultingParams
,
&
$map
=
[])
private
function
replaceNamedArguments
(
$pattern
,
$givenParams
,
&
$resultingParams
,
&
$map
=
[])
{
{
if
((
$tokens
=
$this
->
tokenizePattern
(
$pattern
))
===
false
)
{
if
((
$tokens
=
self
::
tokenizePattern
(
$pattern
))
===
false
)
{
return
false
;
return
false
;
}
}
foreach
(
$tokens
as
$i
=>
$token
)
{
foreach
(
$tokens
as
$i
=>
$token
)
{
...
@@ -214,7 +214,7 @@ class MessageFormatter extends Component
...
@@ -214,7 +214,7 @@ class MessageFormatter extends Component
if
(
!
isset
(
$token
[
2
]))
{
if
(
!
isset
(
$token
[
2
]))
{
return
false
;
return
false
;
}
}
$subtokens
=
$this
->
tokenizePattern
(
$token
[
2
]);
$subtokens
=
self
::
tokenizePattern
(
$token
[
2
]);
$c
=
count
(
$subtokens
);
$c
=
count
(
$subtokens
);
for
(
$k
=
0
;
$k
+
1
<
$c
;
$k
++
)
{
for
(
$k
=
0
;
$k
+
1
<
$c
;
$k
++
)
{
if
(
is_array
(
$subtokens
[
$k
])
||
!
is_array
(
$subtokens
[
++
$k
]))
{
if
(
is_array
(
$subtokens
[
$k
])
||
!
is_array
(
$subtokens
[
++
$k
]))
{
...
@@ -239,7 +239,7 @@ class MessageFormatter extends Component
...
@@ -239,7 +239,7 @@ class MessageFormatter extends Component
*/
*/
protected
function
fallbackFormat
(
$pattern
,
$args
,
$locale
)
protected
function
fallbackFormat
(
$pattern
,
$args
,
$locale
)
{
{
if
((
$tokens
=
$this
->
tokenizePattern
(
$pattern
))
===
false
)
{
if
((
$tokens
=
self
::
tokenizePattern
(
$pattern
))
===
false
)
{
$this
->
_errorCode
=
-
1
;
$this
->
_errorCode
=
-
1
;
$this
->
_errorMessage
=
"Message pattern is invalid."
;
$this
->
_errorMessage
=
"Message pattern is invalid."
;
return
false
;
return
false
;
...
@@ -261,7 +261,7 @@ class MessageFormatter extends Component
...
@@ -261,7 +261,7 @@ class MessageFormatter extends Component
* @param string $pattern patter to tokenize
* @param string $pattern patter to tokenize
* @return array|bool array of tokens or false on failure
* @return array|bool array of tokens or false on failure
*/
*/
private
function
tokenizePattern
(
$pattern
)
private
static
function
tokenizePattern
(
$pattern
)
{
{
$depth
=
1
;
$depth
=
1
;
if
((
$start
=
$pos
=
mb_strpos
(
$pattern
,
'{'
))
===
false
)
{
if
((
$start
=
$pos
=
mb_strpos
(
$pattern
,
'{'
))
===
false
)
{
...
@@ -340,7 +340,7 @@ class MessageFormatter extends Component
...
@@ -340,7 +340,7 @@ class MessageFormatter extends Component
if
(
!
isset
(
$token
[
2
]))
{
if
(
!
isset
(
$token
[
2
]))
{
return
false
;
return
false
;
}
}
$select
=
s
tatic
::
tokenizePattern
(
$token
[
2
]);
$select
=
s
elf
::
tokenizePattern
(
$token
[
2
]);
$c
=
count
(
$select
);
$c
=
count
(
$select
);
$message
=
false
;
$message
=
false
;
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
...
@@ -368,7 +368,7 @@ class MessageFormatter extends Component
...
@@ -368,7 +368,7 @@ class MessageFormatter extends Component
if
(
!
isset
(
$token
[
2
]))
{
if
(
!
isset
(
$token
[
2
]))
{
return
false
;
return
false
;
}
}
$plural
=
s
tatic
::
tokenizePattern
(
$token
[
2
]);
$plural
=
s
elf
::
tokenizePattern
(
$token
[
2
]);
$c
=
count
(
$plural
);
$c
=
count
(
$plural
);
$message
=
false
;
$message
=
false
;
$offset
=
0
;
$offset
=
0
;
...
...
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