Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13143701
LocalizableMessage.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
LocalizableMessage.php
View Options
<?php
namespace
AuthGrove\Internationalization
;
class
LocalizableMessage
{
///
/// Properties
///
/**
* The prefix to use to get l10n
*
* @var string
*/
protected
$prefix
=
''
;
/**
* The message to localize
*
* @var string
*/
protected
$message
;
/**
* The current representation of the message string
*
* @var string
*/
protected
$string
;
///
/// Constructor
///
/**
* Represents a new instance of the LocalizableMessage class
*/
public
function
__construct
(
$message
)
{
$this
->
message
=
$message
;
$this
->
string
=
$message
;
// By default, it contains unlocalized text.
}
///
/// L10n methods
///
/**
* @return LocalizableMessage
*/
public
function
localize
()
{
$this
->
string
=
trans
(
$this
->
prefix
.
$this
->
message
);
return
$this
;
}
///
/// Transformation methods
///
/**
* Replaces spaces by no breaking spaces
* @return LocalizableMessage
*/
public
function
replaceSpacesByNonBreakableSpaces
()
{
$nbsp
=
self
::
getNonBreakableSpace
();
$this
->
string
=
str_replace
(
' '
,
$nbsp
,
$this
->
string
);
return
$this
;
}
/**
* Pads the message
*
* @param int $len The length of the taget string
*/
public
function
pad
(
$len
)
{
$this
->
string
=
\Keruald\mb_str_pad
(
$this
->
string
,
$len
);
return
$this
;
}
///
/// Output methods
///
/**
* Gets a string representation of the message
* @var string
*/
public
function
get
()
{
return
$this
->
string
;
}
///
/// Static helpers methods
///
/**
* Gets non breakable space
*/
public
static
function
getNonBreakableSpace
()
{
return
mb_convert_encoding
(
' '
,
'UTF-8'
,
'HTML-ENTITIES'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 16:48 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3188623
Default Alt Text
LocalizableMessage.php (1 KB)
Attached To
Mode
rGROVE Auth Grove
Attached
Detach File
Event Timeline
Log In to Comment