[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Language/ -> Text.php (summary)

Joomla! Content Management System

Copyright: (C) 2007 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 379 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Text:: (8 methods):
  _()
  passSprintf()
  alt()
  plural()
  sprintf()
  printf()
  script()
  getScriptStrings()


Class: Text  - X-Ref

Text handling class.

_($string, $jsSafe = false, $interpretBackSlashes = true, $script = false)   X-Ref
Translates a string into the current language.

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

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

passSprintf(&$string, $jsSafe = false, $interpretBackSlashes = true, $script = false)   X-Ref
Checks the string if it should be interpreted as sprintf and runs sprintf over it.

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

alt($string, $alt, $jsSafe = false, $interpretBackSlashes = true, $script = false)   X-Ref
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

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

plural($string, $n)   X-Ref
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.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

param: string   $string  The format string.
param: integer  $n       The number of items
return: string  The translated strings or the key if 'script' is true in the array of options

sprintf($string)   X-Ref
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.

param: string  $string  The format string.
return: string  The translated strings or the key if 'script' is true in the array of options.

printf($string)   X-Ref
Passes a string thru an printf.

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

param: string  $string  The format string.
return: mixed

script($string = null, $jsSafe = false, $interpretBackSlashes = true)   X-Ref
Translate a string into the current language and stores it in the JavaScript language store.

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

getScriptStrings()   X-Ref
Get the strings that have been loaded to the JavaScript language store.

return: array



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer