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
7022d93b
Commit
7022d93b
authored
Dec 12, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1498 from mintao/master
i18N: View path does not change if language folder exists
parents
05c67f43
ff7c25ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
BaseFileHelper.php
framework/yii/helpers/BaseFileHelper.php
+1
-1
FileHelperTest.php
tests/unit/framework/helpers/FileHelperTest.php
+25
-0
No files found.
framework/yii/helpers/BaseFileHelper.php
View file @
7022d93b
...
@@ -68,7 +68,7 @@ class BaseFileHelper
...
@@ -68,7 +68,7 @@ class BaseFileHelper
if
(
$language
===
$sourceLanguage
)
{
if
(
$language
===
$sourceLanguage
)
{
return
$file
;
return
$file
;
}
}
$desiredFile
=
dirname
(
$file
)
.
DIRECTORY_SEPARATOR
.
$
sourceL
anguage
.
DIRECTORY_SEPARATOR
.
basename
(
$file
);
$desiredFile
=
dirname
(
$file
)
.
DIRECTORY_SEPARATOR
.
$
l
anguage
.
DIRECTORY_SEPARATOR
.
basename
(
$file
);
return
is_file
(
$desiredFile
)
?
$desiredFile
:
$file
;
return
is_file
(
$desiredFile
)
?
$desiredFile
:
$file
;
}
}
...
...
tests/unit/framework/helpers/FileHelperTest.php
View file @
7022d93b
...
@@ -313,4 +313,29 @@ class FileHelperTest extends TestCase
...
@@ -313,4 +313,29 @@ class FileHelperTest extends TestCase
{
{
$this
->
assertEquals
(
DIRECTORY_SEPARATOR
.
'home'
.
DIRECTORY_SEPARATOR
.
'demo'
,
FileHelper
::
normalizePath
(
'/home\demo/'
));
$this
->
assertEquals
(
DIRECTORY_SEPARATOR
.
'home'
.
DIRECTORY_SEPARATOR
.
'demo'
,
FileHelper
::
normalizePath
(
'/home\demo/'
));
}
}
public
function
testLocalizedDirectory
()
{
$this
->
createFileStructure
([
'views'
=>
[
'faq.php'
=>
'English FAQ'
,
'de-DE'
=>
[
'faq.php'
=>
'German FAQ'
,
],
],
]);
$viewFile
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'views'
.
DIRECTORY_SEPARATOR
.
'faq.php'
;
$sourceLanguage
=
'en-US'
;
// Source language and target language are same. The view path should be unchanged.
$currentLanguage
=
$sourceLanguage
;
$this
->
assertSame
(
$viewFile
,
FileHelper
::
localize
(
$viewFile
,
$currentLanguage
,
$sourceLanguage
));
// Source language and target language are different. The view path should be changed.
$currentLanguage
=
'de-DE'
;
$this
->
assertSame
(
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'views'
.
DIRECTORY_SEPARATOR
.
$currentLanguage
.
DIRECTORY_SEPARATOR
.
'faq.php'
,
FileHelper
::
localize
(
$viewFile
,
$currentLanguage
,
$sourceLanguage
)
);
}
}
}
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