Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
ea6b58b2
Commit
ea6b58b2
authored
Jul 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring lang class.
parent
c5ddb67d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
lang.php
system/lang.php
+9
-8
No files found.
system/lang.php
View file @
ea6b58b2
...
@@ -28,6 +28,10 @@ class Lang {
...
@@ -28,6 +28,10 @@ class Lang {
/**
/**
* Create a new Lang instance.
* Create a new Lang instance.
*
*
* Language lines are retrieved using "dot" notation. So, asking for the
* "messages.required" language line would return the "required" line
* from the "messages" language file.
*
* @param string $line
* @param string $line
* @return void
* @return void
*/
*/
...
@@ -63,7 +67,6 @@ class Lang {
...
@@ -63,7 +67,6 @@ class Lang {
if
(
!
array_key_exists
(
$language
.
$file
,
static
::
$lines
))
if
(
!
array_key_exists
(
$language
.
$file
,
static
::
$lines
))
{
{
// The language file doesn't exist, return the default value.
$line
=
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
$line
=
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
}
}
else
else
...
@@ -82,13 +85,14 @@ class Lang {
...
@@ -82,13 +85,14 @@ class Lang {
/**
/**
* Parse a language key.
* Parse a language key.
*
*
* The value on the left side of the dot is the language file name,
* while the right side of the dot is the item within that file.
*
* @param string $key
* @param string $key
* @return array
* @return array
*/
*/
private
function
parse
(
$key
)
private
function
parse
(
$key
)
{
{
// The left side of the dot is the file name, while the right side of the dot
// is the item within that file being requested.
$segments
=
explode
(
'.'
,
$key
);
$segments
=
explode
(
'.'
,
$key
);
if
(
count
(
$segments
)
<
2
)
if
(
count
(
$segments
)
<
2
)
...
@@ -108,14 +112,11 @@ class Lang {
...
@@ -108,14 +112,11 @@ class Lang {
*/
*/
private
function
load
(
$file
,
$language
)
private
function
load
(
$file
,
$language
)
{
{
// If we have already loaded the language file or the file doesn't exist, bail out.
if
(
!
array_key_exists
(
$language
.
$file
,
static
::
$lines
)
and
file_exists
(
$path
=
APP_PATH
.
'lang/'
.
$language
.
'/'
.
$file
.
EXT
))
if
(
array_key_exists
(
$language
.
$file
,
static
::
$lines
)
or
!
file_exists
(
$path
=
APP_PATH
.
'lang/'
.
$language
.
'/'
.
$file
.
EXT
))
{
{
return
;
}
static
::
$lines
[
$language
.
$file
]
=
require
$path
;
static
::
$lines
[
$language
.
$file
]
=
require
$path
;
}
}
}
/**
/**
* Set the place-holder replacements.
* Set the place-holder replacements.
...
...
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