Text
Text handling class.
since |
1.7.0 |
---|---|
package |
Joomla CMS |
Methods
_
Translates a string into the current language.
_( string, jsSafe = false, interpretBackSlashes = true, script = false) :
Examples:
<script>alert(Joomla.Text._('<?php echo Text::_("JDEFAULT", array("script"=>true)); ?>'));</script>
will generate an alert message containing 'Default'
<?php echo Text::_("JDEFAULT"); ?>
will generate a 'Default' string
since |
1.7.0 |
---|
Arguments
- string
string
The string to translate.- jsSafe
mixed
Boolean: Make the result javascript safe.- interpretBackSlashes
bool
To interpret backslashes (\=, \n=carriage return, \t=tabulation)- script
bool
To indicate that the string will be push in the javascript language store
Response
string
The translated string or the key if $script is true
alt
Translates a string into the current language.
alt( string, alt, jsSafe = false, interpretBackSlashes = true, script = false) :
Examples:
<?php echo Text::alt('JALL', 'language'); ?>
will generate a 'All' string in English but a "Toutes" string in French
<?php echo Text::alt('JALL', 'module'); ?>
will generate a 'All' string in English but a "Tous" string in French
since |
1.7.0 |
---|
Arguments
- string
string
The string to translate.- alt
string
The alternate option for global string- jsSafe
mixed
Boolean: Make the result javascript safe.- interpretBackSlashes
bool
To interpret backslashes (\=, \n=carriage return, \t=tabulation)- script
bool
To indicate that the string will be pushed in the javascript language store
Response
string
The translated string or the key if $script is true
getScriptStrings
Get the strings that have been loaded to the JavaScript language store.
getScriptStrings() : mixed||string|int
since |
3.7.0 |
---|
Response
array<string|int, mixed>
passSprintf
Checks the string if it should be interpreted as sprintf and runs sprintf over it.
passSprintf( &string, jsSafe = false, interpretBackSlashes = true, script = false) :
since |
3.4.4 |
---|
Arguments
- string
string
The string to translate.- jsSafe
mixed
Boolean: Make the result javascript safe.- interpretBackSlashes
bool
To interpret backslashes (\=, \n=carriage return, \t=tabulation)- script
bool
To indicate that the string will be push in the javascript language store
Response
bool
Whether the string be interpreted as sprintf
plural
Like Text::sprintf but tries to pluralise the string.
plural( string, n) :
Note that this method can take a mixed number of arguments as for the sprintf function.
The last argument can take an array of options:
array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
where:
jsSafe is a boolean to generate a javascript safe strings. interpretBackSlashes is a boolean to interpret backslashes \->, \n->new line, \t->tabulation. script is a boolean to indicate that the string will be push in the javascript language store.
Examples:
<script>alert(Joomla.Text._('<?php echo Text::plural("COM_PLUGINS_N_ITEMS_UNPUBLISHED", 1, array("script"=>true)); ?>'));</script>
will generate an alert message containing '1 plugin successfully disabled'
<?php echo Text::plural('COM_PLUGINS_N_ITEMS_UNPUBLISHED', 1); ?>
will generate a '1 plugin successfully disabled' string
since |
1.7.0 |
---|
Arguments
- string
string
The format string.- n
int
The number of items
Response
string
The translated strings or the key if 'script' is true in the array of options
printf
Passes a string through a printf.
printf( string) :
Note that this method can take a mixed number of arguments as for the sprintf function.
since |
1.7.0 |
---|
Arguments
- string
string
The format string.
Response
mixed
script
Translate a string into the current language and stores it in the JavaScript language store.
script( string = null, jsSafe = false, interpretBackSlashes = true) : mixed||string|int
since |
1.7.0 |
---|
Arguments
- string
string
The Text key.- jsSafe
bool
Legacy parameter to add slashes to the string. Set it as "false" because the method encodes the string as JSON with json_encode().- interpretBackSlashes
bool
Interpret \t and \n.
Response
array<string|int, mixed>
sprintf
Passes a string thru a sprintf.
sprintf( string) :
Note that this method can take a mixed number of arguments as for the sprintf function.
The last argument can take an array of options:
array('jsSafe'=>boolean, 'interpretBackSlashes'=>boolean, 'script'=>boolean)
where:
jsSafe is a boolean to generate a javascript safe strings. interpretBackSlashes is a boolean to interpret backslashes \->, \n->new line, \t->tabulation. script is a boolean to indicate that the string will be push in the javascript language store.
since |
1.7.0 |
---|
Arguments
- string
string
The format string.
Response
string
The translated strings or the key if 'script' is true in the array of options.
Properties
strings
JavaScript strings
since |
1.7.0 |
---|
Type(s)
array<string|int, mixed>