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
ff7c25ea
Commit
ff7c25ea
authored
Dec 12, 2013
by
Florian Fackler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1497 (wrong file rendered if language != sourceLanguage)
parent
85b5c75b
Hide 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 @
ff7c25ea
...
...
@@ -68,7 +68,7 @@ class BaseFileHelper
if
(
$language
===
$sourceLanguage
)
{
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
;
}
...
...
tests/unit/framework/helpers/FileHelperTest.php
View file @
ff7c25ea
...
...
@@ -313,4 +313,29 @@ class FileHelperTest extends TestCase
{
$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