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
9f37e133
Commit
9f37e133
authored
Feb 23, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test break.
parent
2a6bc68c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
MessageSource.php
framework/i18n/MessageSource.php
+1
-3
I18NTest.php
tests/unit/framework/i18n/I18NTest.php
+3
-2
No files found.
framework/i18n/MessageSource.php
View file @
9f37e133
...
@@ -116,10 +116,8 @@ class MessageSource extends Component
...
@@ -116,10 +116,8 @@ class MessageSource extends Component
$this
->
trigger
(
self
::
EVENT_MISSING_TRANSLATION
,
$event
);
$this
->
trigger
(
self
::
EVENT_MISSING_TRANSLATION
,
$event
);
if
(
$event
->
translatedMessage
!==
null
)
{
if
(
$event
->
translatedMessage
!==
null
)
{
return
$this
->
_messages
[
$key
][
$message
]
=
$event
->
translatedMessage
;
return
$this
->
_messages
[
$key
][
$message
]
=
$event
->
translatedMessage
;
}
else
{
return
$this
->
_messages
[
$key
][
$message
]
=
false
;
}
}
}
}
return
false
;
return
$this
->
_messages
[
$key
][
$message
]
=
false
;
}
}
}
}
tests/unit/framework/i18n/I18NTest.php
View file @
9f37e133
...
@@ -116,13 +116,14 @@ class I18NTest extends TestCase
...
@@ -116,13 +116,14 @@ class I18NTest extends TestCase
Event
::
off
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
);
Event
::
off
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
);
Event
::
on
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
,
function
(
$event
)
{
Event
::
on
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
,
function
(
$event
)
{
if
(
$event
->
message
==
'
M
issing translation message.'
)
{
if
(
$event
->
message
==
'
New m
issing translation message.'
)
{
$event
->
translatedMessage
=
'TRANSLATION MISSING HERE!'
;
$event
->
translatedMessage
=
'TRANSLATION MISSING HERE!'
;
}
}
});
});
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Another missing translation message.'
,
$this
->
i18n
->
translate
(
'test'
,
'Another missing translation message.'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Another missing translation message.'
,
$this
->
i18n
->
translate
(
'test'
,
'Another missing translation message.'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'TRANSLATION MISSING HERE!'
,
$this
->
i18n
->
translate
(
'test'
,
'Missing translation message.'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Missing translation message.'
,
$this
->
i18n
->
translate
(
'test'
,
'Missing translation message.'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'TRANSLATION MISSING HERE!'
,
$this
->
i18n
->
translate
(
'test'
,
'New missing translation message.'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
Event
::
off
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
);
Event
::
off
(
PhpMessageSource
::
className
(),
PhpMessageSource
::
EVENT_MISSING_TRANSLATION
);
}
}
...
...
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