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
d49957fe
Commit
d49957fe
authored
Sep 18, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #5079: added test case.
parent
4a31628b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
I18NTest.php
tests/unit/framework/i18n/I18NTest.php
+31
-0
No files found.
tests/unit/framework/i18n/I18NTest.php
View file @
d49957fe
...
@@ -54,6 +54,37 @@ class I18NTest extends TestCase
...
@@ -54,6 +54,37 @@ class I18NTest extends TestCase
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Hallo Welt!'
,
$this
->
i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
}
}
public
function
testDefaultSource
()
{
$i18n
=
new
I18N
([
'translations'
=>
[
'*'
=>
new
PhpMessageSource
([
'basePath'
=>
'@yiiunit/data/i18n/messages'
,
'fileMap'
=>
[
'test'
=>
'test.php'
,
'foo'
=>
'test.php'
,
],
])
]
]);
$msg
=
'The dog runs fast.'
;
// source = target. Should be returned as is.
$this
->
assertEquals
(
$msg
,
$i18n
->
translate
(
'test'
,
$msg
,
[],
'en'
));
// exact match
$this
->
assertEquals
(
'Der Hund rennt schnell.'
,
$i18n
->
translate
(
'test'
,
$msg
,
[],
'de-DE'
));
$this
->
assertEquals
(
'Der Hund rennt schnell.'
,
$i18n
->
translate
(
'foo'
,
$msg
,
[],
'de-DE'
));
$this
->
assertEquals
(
$msg
,
$i18n
->
translate
(
'bar'
,
$msg
,
[],
'de-DE'
));
// fallback to just language code with absent exact match
$this
->
assertEquals
(
'Собака бегает быстро.'
,
$i18n
->
translate
(
'test'
,
$msg
,
[],
'ru-RU'
));
// fallback to just langauge code with present exact match
$this
->
assertEquals
(
'Hallo Welt!'
,
$i18n
->
translate
(
'test'
,
'Hello world!'
,
[],
'de-DE'
));
}
public
function
testTranslateParams
()
public
function
testTranslateParams
()
{
{
$msg
=
'His speed is about {n} km/h.'
;
$msg
=
'His speed is about {n} km/h.'
;
...
...
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