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
40b3c2e8
Commit
40b3c2e8
authored
Feb 09, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2209: When I18N message translation is missing source language is now used for formatting
parent
83a459cc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
I18N.php
framework/i18n/I18N.php
+7
-2
MessageSource.php
framework/i18n/MessageSource.php
+4
-6
BaseListView.php
framework/widgets/BaseListView.php
+13
-7
No files found.
framework/CHANGELOG.md
View file @
40b3c2e8
...
@@ -41,6 +41,7 @@ Yii Framework 2 Change Log
...
@@ -41,6 +41,7 @@ Yii Framework 2 Change Log
-
Bug #2084: AssetController adjusting CSS URLs declared at same line fixed (klimov-paul)
-
Bug #2084: AssetController adjusting CSS URLs declared at same line fixed (klimov-paul)
-
Bug #2091:
`QueryBuilder::buildInCondition()`
fails to handle array not starting with index 0 (qiangxue)
-
Bug #2091:
`QueryBuilder::buildInCondition()`
fails to handle array not starting with index 0 (qiangxue)
-
Bug #2160: SphinxQL does not support OFFSET (qiangxue, romeo7)
-
Bug #2160: SphinxQL does not support OFFSET (qiangxue, romeo7)
-
Bug #2209: When I18N message translation is missing source language is now used for formatting (samdark)
-
Bug #2212:
`yii\gridview\DataColumn`
generates incorrect labels when used with nosql DB and there is no data (qiangxue)
-
Bug #2212:
`yii\gridview\DataColumn`
generates incorrect labels when used with nosql DB and there is no data (qiangxue)
-
Bug #2298: Fixed the bug that Gii controller generator did not allow digit in the controller ID (qiangxue)
-
Bug #2298: Fixed the bug that Gii controller generator did not allow digit in the controller ID (qiangxue)
-
Bug #2303: Fixed the bug that
`yii\base\Theme::pathMap`
did not support dynamic update with path aliases (qiangxue)
-
Bug #2303: Fixed the bug that
`yii\base\Theme::pathMap`
did not support dynamic update with path aliases (qiangxue)
...
...
framework/i18n/I18N.php
View file @
40b3c2e8
...
@@ -85,8 +85,13 @@ class I18N extends Component
...
@@ -85,8 +85,13 @@ class I18N extends Component
*/
*/
public
function
translate
(
$category
,
$message
,
$params
,
$language
)
public
function
translate
(
$category
,
$message
,
$params
,
$language
)
{
{
$message
=
$this
->
getMessageSource
(
$category
)
->
translate
(
$category
,
$message
,
$language
);
$messageSource
=
$this
->
getMessageSource
(
$category
);
return
$this
->
format
(
$message
,
$params
,
$language
);
$translation
=
$messageSource
->
translate
(
$category
,
$message
,
$language
);
if
(
$translation
===
false
)
{
return
$this
->
format
(
$message
,
$params
,
$messageSource
->
sourceLanguage
);
}
else
{
return
$this
->
format
(
$translation
,
$params
,
$language
);
}
}
}
/**
/**
...
...
framework/i18n/MessageSource.php
View file @
40b3c2e8
...
@@ -78,14 +78,14 @@ class MessageSource extends Component
...
@@ -78,14 +78,14 @@ class MessageSource extends Component
* @param string $category the message category
* @param string $category the message category
* @param string $message the message to be translated
* @param string $message the message to be translated
* @param string $language the target language
* @param string $language the target language
* @return string
the translated message (or the original message if translation is not needed)
* @return string
|boolean the translated message or false if translation wasn't found or isn't required
*/
*/
public
function
translate
(
$category
,
$message
,
$language
)
public
function
translate
(
$category
,
$message
,
$language
)
{
{
if
(
$this
->
forceTranslation
||
$language
!==
$this
->
sourceLanguage
)
{
if
(
$this
->
forceTranslation
||
$language
!==
$this
->
sourceLanguage
)
{
return
$this
->
translateMessage
(
$category
,
$message
,
$language
);
return
$this
->
translateMessage
(
$category
,
$message
,
$language
);
}
else
{
}
else
{
return
$messag
e
;
return
fals
e
;
}
}
}
}
...
@@ -96,7 +96,7 @@ class MessageSource extends Component
...
@@ -96,7 +96,7 @@ class MessageSource extends Component
* @param string $category the category that the message belongs to
* @param string $category the category that the message belongs to
* @param string $message the message to be translated
* @param string $message the message to be translated
* @param string $language the target language
* @param string $language the target language
* @return string
the translated message
* @return string
|boolean the translated message or false if translation wasn't found
*/
*/
protected
function
translateMessage
(
$category
,
$message
,
$language
)
protected
function
translateMessage
(
$category
,
$message
,
$language
)
{
{
...
@@ -113,9 +113,7 @@ class MessageSource extends Component
...
@@ -113,9 +113,7 @@ class MessageSource extends Component
'language'
=>
$language
,
'language'
=>
$language
,
]);
]);
$this
->
trigger
(
self
::
EVENT_MISSING_TRANSLATION
,
$event
);
$this
->
trigger
(
self
::
EVENT_MISSING_TRANSLATION
,
$event
);
return
$this
->
_messages
[
$key
]
=
$event
->
message
;
}
else
{
return
$message
;
}
}
return
false
;
}
}
}
}
framework/widgets/BaseListView.php
View file @
40b3c2e8
...
@@ -160,25 +160,31 @@ abstract class BaseListView extends Widget
...
@@ -160,25 +160,31 @@ abstract class BaseListView extends Widget
$page
=
$pagination
->
getPage
()
+
1
;
$page
=
$pagination
->
getPage
()
+
1
;
$pageCount
=
$pagination
->
pageCount
;
$pageCount
=
$pagination
->
pageCount
;
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
$summaryContent
=
'<div class="summary">'
return
'<div class="summary">'
.
Yii
::
t
(
'yii'
,
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'
)
.
Yii
::
t
(
'yii'
,
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'
,
[
'begin'
=>
$begin
,
'end'
=>
$end
,
'count'
=>
$count
,
'totalCount'
=>
$totalCount
,
'page'
=>
$page
,
'pageCount'
=>
$pageCount
,
])
.
'</div>'
;
.
'</div>'
;
}
}
}
else
{
}
else
{
$begin
=
$page
=
$pageCount
=
1
;
$begin
=
$page
=
$pageCount
=
1
;
$end
=
$totalCount
=
$count
;
$end
=
$totalCount
=
$count
;
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
$summaryContent
=
'<div class="summary">'
.
Yii
::
t
(
'yii'
,
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.'
)
.
'</div>'
;
return
'<div class="summary">'
.
Yii
::
t
(
'yii'
,
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.'
,
[
}
}
return
Yii
::
$app
->
getI18n
()
->
format
(
$summaryContent
,
[
'begin'
=>
$begin
,
'begin'
=>
$begin
,
'end'
=>
$end
,
'end'
=>
$end
,
'count'
=>
$count
,
'count'
=>
$count
,
'totalCount'
=>
$totalCount
,
'totalCount'
=>
$totalCount
,
'page'
=>
$page
,
'page'
=>
$page
,
'pageCount'
=>
$pageCount
,
'pageCount'
=>
$pageCount
,
],
Yii
::
$app
->
language
);
])
.
'</div>'
;
}
}
}
}
/**
/**
...
...
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