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
6c7672c5
Commit
6c7672c5
authored
Jun 07, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of t().
parent
c0ab801f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
11 deletions
+3
-11
YiiBase.php
framework/yii/YiiBase.php
+1
-4
I18N.php
framework/yii/i18n/I18N.php
+2
-7
No files found.
framework/yii/YiiBase.php
View file @
6c7672c5
...
...
@@ -606,10 +606,7 @@ class YiiBase
public
static
function
t
(
$category
,
$message
,
$params
=
array
(),
$language
=
null
)
{
if
(
self
::
$app
!==
null
)
{
if
(
$language
===
null
)
{
$language
=
self
::
$app
->
language
;
}
return
self
::
$app
->
getI18N
()
->
translate
(
$category
,
$message
,
$language
);
return
self
::
$app
->
getI18N
()
->
translate
(
$category
,
$message
,
$params
,
$language
?:
self
::
$app
->
language
);
}
else
{
return
is_array
(
$params
)
?
strtr
(
$message
,
$params
)
:
$message
;
}
...
...
framework/yii/i18n/I18N.php
View file @
6c7672c5
...
...
@@ -78,16 +78,11 @@ class I18N extends Component
* @param string $category the message category.
* @param string $message the message to be translated.
* @param array $params the parameters that will be used to replace the corresponding placeholders in the message.
* @param string $language the language code (e.g. `en_US`, `en`). If this is null, the current
* [[\yii\base\Application::language|application language]] will be used.
* @param string $language the language code (e.g. `en_US`, `en`).
* @return string the translated message.
*/
public
function
translate
(
$category
,
$message
,
$params
=
array
(),
$language
=
null
)
public
function
translate
(
$category
,
$message
,
$params
,
$language
)
{
if
(
$language
===
null
)
{
$language
=
Yii
::
$app
->
language
;
}
$message
=
$this
->
getMessageSource
(
$category
)
->
translate
(
$category
,
$message
,
$language
);
if
(
!
is_array
(
$params
))
{
...
...
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