API16

JLanguage/

From Joomla! Documentation

< API16:JLanguage
Revision as of 22:03, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Translate function, mimics the php gettext (alias _) function

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

_($string, $jsSafe=false)
Parameter Name Default Value Description
$string $string The string to translate
$jsSafe false $jsSafe Make the result javascript safe

Returns[edit]

string The translation of the string

Defined in[edit]

libraries/joomla/language/language.php

Importing[edit]

jimport( 'joomla.language.language' );

Source Body[edit]

public function _($string, $jsSafe = false)
{
        $key = strtoupper($string);
        if (isset ($this->_strings[$key])) {
                $string = $this->_debug ? '**'.$this->_strings[$key].'**' : $this->_strings[$key];

                // Store debug information
                if ($this->_debug) {
                        $caller = $this->_getCallerInfo();

                        if (! array_key_exists($key, $this->_used)) {
                                $this->_used[$key] = array();
                        }

                        $this->_used[$key][] = $caller;
                }
        } else {
                if ($this->_debug) {
                        $caller = $this->_getCallerInfo();
                        $caller['string'] = $string;

                        if (! array_key_exists($key, $this->_orphans)) {
                                $this->_orphans[$key] = array();
                        }

                        $this->_orphans[$key][] = $caller;

                        $string = '??'.$string.'??';
                }
        }

        if ($jsSafe) {
                $string = addslashes($string);
        }

        return $string;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />