API16

JText/script: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JText/script}}
 


===Syntax===
===Syntax===
Line 50: Line 50:




{{subst:SeeAlso:JText/script}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=script
  category=script
  category=JText
  category=JText
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:13, 25 March 2017

Description

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



Syntax

static script($string=null)
Parameter Name Default Value Description
$string null $string The key.

Returns

void

Defined in

libraries/joomla/methods.php

Importing

jimport( 'joomla.methods' );

Source Body

public static function script($string = null)
{
        static $strings;

        // Instante the array if necessary.
        if (!is_array($strings)) {
                $strings = array();
        }

        // Add the string to the array if not null.
        if ($string !== null) {
                // Normalize the key and translate the string.
                $strings[strtoupper($string)] = JFactory::getLanguage()->_($string);
        }

        return $strings;
}



Examples

Code Examples