class Text

Text handling class.

Methods

static  string
_( string $string, mixed $jsSafe = false, boolean $interpretBackSlashes = true, boolean $script = false)

Translates a string into the current language.

static  string
alt( string $string, string $alt, mixed $jsSafe = false, boolean $interpretBackSlashes = true, boolean $script = false)

Translates a string into the current language.

static  string
plural( string $string, integer $n)

Like Text::sprintf but tries to pluralise the string.

static  string
sprintf( string $string)

Passes a string thru a sprintf.

static  mixed
printf( string $string)

Passes a string thru an printf.

static  string
script( string $string = null, boolean $jsSafe = false, boolean $interpretBackSlashes = true)

Translate a string into the current language and stores it in the JavaScript language store.

static  array
getScriptStrings()

Get the strings that have been loaded to the JavaScript language store.

Details

static string _( string $string, mixed $jsSafe = false, boolean $interpretBackSlashes = true, boolean $script = false)

Translates a string into the current language.

Examples: <script>alert(Joomla.JText._('<?php echo Text::_("JDEFAULT", array("script"=>true)); ?>'));</script> will generate an alert message containing 'Default' <?php echo Text::_("JDEFAULT"); ?> will generate a 'Default' string

Parameters

string $string The string to translate.
mixed $jsSafe Boolean: Make the result javascript safe.
boolean $interpretBackSlashes To interpret backslashes (\=\, \n=carriage return, \t=tabulation)
boolean $script To indicate that the string will be push in the javascript language store

Return Value

string The translated string or the key if $script is true

static string alt( string $string, string $alt, mixed $jsSafe = false, boolean $interpretBackSlashes = true, boolean $script = false)

Translates a string into the current language.

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

Parameters

string $string The string to translate.
string $alt The alternate option for global string
mixed $jsSafe Boolean: Make the result javascript safe.
boolean $interpretBackSlashes To interpret backslashes (\=\, \n=carriage return, \t=tabulation)
boolean $script To indicate that the string will be pushed in the javascript language store

Return Value

string The translated string or the key if $script is true

static string plural( string $string, integer $n)

Like Text::sprintf but tries to pluralise the 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.

Examples: <script>alert(Joomla.JText._('<?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

Parameters

string $string The format string.
integer $n The number of items

Return Value

string The translated strings or the key if 'script' is true in the array of options

static string sprintf( string $string)

Passes a string thru a sprintf.

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.

Parameters

string $string The format string.

Return Value

string The translated strings or the key if 'script' is true in the array of options.

static mixed printf( string $string)

Passes a string thru an printf.

Note that this method can take a mixed number of arguments as for the sprintf function.

Parameters

string $string The format string.

Return Value

mixed

static string script( string $string = null, boolean $jsSafe = false, boolean $interpretBackSlashes = true)

Translate a string into the current language and stores it in the JavaScript language store.

Parameters

string $string The Text key.
boolean $jsSafe Ensure the output is JavaScript safe.
boolean $interpretBackSlashes Interpret \t and \n.

Return Value

string

static array getScriptStrings()

Get the strings that have been loaded to the JavaScript language store.

Return Value

array