API15

Difference between revisions of "JLanguage/"

From Joomla! Documentation

< API15:JLanguage
(New page: ===Description=== Translate function, mimics the php gettext (alias _) function <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JLanguage/_|Edit Desc...)
 
m (preparing for archive only)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JLanguage/_|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JLanguage/_}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 104: Line 104:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JLanguage/_|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JLanguage/_}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=_
 
  category=_
 
  category=JLanguage
 
  category=JLanguage
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 19:55, 24 March 2017

The "API15" 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]

function _($string, $jsSafe = false)
{
        //$key = str_replace( ' ', '_', strtoupper( trim( $string ) ) );echo '<br />'.$key;
        $key = strtoupper($string);
        $key = substr($key, 0, 1) == '_' ? substr($key, 1) : $key;

        if (isset ($this->_strings[$key]))
        {
                $string = $this->_debug ? "&bull;".$this->_strings[$key]."&bull;" : $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 (defined($string))
                {
                        $string = $this->_debug ? '!!'.constant($string).'!!' : constant($string);

                        // 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]

Code Examples[edit]