Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Language  /  Locale   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tl.gif Form tr.gif tls.gif     Language  trs.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.gif tl.gif Netbank.eksperter.dk tr.gif tl.gif Tab tr.gif tl.gif Table tr.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

Locale.php


Vis: Sample code, tutorial

Locale, Sample code, tutorial

Sådan benyttes komponenten Locale klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/Locale.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    Locale
    ::display($param1$param2$param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object 
    = new Locale($param1$param2$param3, ...);
    print 
    $object->getHtml();
    ?>

Skjul: Sådan vises komponenten

Locale, Sådan vises komponenten

Sådan vises komponenten Locale klassen


Vis: PHP source code

Locale, PHP source code

Den fulde PHP kildekode for Locale klassen

<?php
/**
 * @package language
 * @see HTML_LANGUAGE_UTIL_PATH.'/Locale.php'
 * @copyright (c) http://Finn-Rasmussen.com
 * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
 * @author http://Finn-Rasmussen.com
 * @version 1.11
 * @since 27-nov-2009
 */

/**
 * The required files
 */
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
require_once(
HTML_BASE_UTIL_PATH.'/Script.php');

/**
 * The Locale object.
 * A Locale object represents a specific geographical, political, or cultural region. 
 * An operation that requires a Locale to perform its task is called locale-sensitive and 
 * uses the Locale to tailor information for the user. 
 * For example, displaying a number is a locale-sensitive operation--the number should be 
 * formatted according to the customs/conventions of the user's native country, region, or culture. 
 * <code>
 * Usage:
 *    $locale = new Locale($language, $country);
 *    print $locale->getLanguage();
 *    print $locale->getCountry();
 * Or
 *    print Locale::language($language, $country);
 *    print Locale::country($language, $country);
 * Or
 *    script = $locale->getHtml();
 * Or
 *    Locale::display();
 * </code>
 * @package language 
 */
class Locale extends Html {
    
/**
     * @var String $language The Language
     */
    
protected $language '';
    
    
/**
     * @var String $country The Country
     */
    
protected $country '';

    
/**
     * Constructor
     * @param String $language The Language
     * @param String $country  The Country
     */
    
function __construct($language='da'$country='DK') {
        
$this->language $language != '' $language LANGUAGE;
        
$this->country  $country  != '' $country  : @COUNTRY;
        
/**
         * If no country is specified, then try to figure out the country name
         * from the language in question
         */
        
if ($this->country == '') {
            if (
array_key_exists($this->language$GLOBALS[DEFINE_COUNTRY])) {
                
$this->country $GLOBALS[DEFINE_COUNTRY][$this->language];
            }
        }
        
parent::__construct();
    }
    
    
/**
     * Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
     * @return String Return the Language
     */
     
function getLanguage() {
         return 
$this->language;
     }
     
    
/**
     * Returns the country/region code for this locale, which will either be the empty string or an upercase ISO 3166 2-letter code.
     * @return String Return the Country
     */
     
function getCountry() {
         return 
$this->country;
     }
     
     
/**
      * Get the html for the Locale class
      * @return String The html
      */
     
function getHtml() {
         
$html "";
        
$language $this->getLanguage();
        
$country  $this->getCountry();
        
// Get the current Locale
        
$script = new Script();
        
$script->add("var thisLocale = Locale.getInstance('$language', '$country');");
//         if (array_key_exists(DEFINE_COUNTRY, $GLOBALS)) {
//             $html .= "<ul>\r\n";
//             foreach($GLOBALS[DEFINE_COUNTRY] as $key=>$value) {
//                 $html .= "<li>$key=>$value</li>\r\n";
//             }
//             $html .= "</ul>\r\n";
//         }
        
$html .= $script->getHtml();
         return 
$html;
     }
     
     public static function 
display() {
        
$html = new Locale();
        
$html->addHtml();
     }
}
?>

Vis: HTML source code

Locale, HTML source code

Den fulde HTML kildekode for Locale klassen

<?
<!-- DEBUGScript -->
<
script type="text/javascript">
//<![CDATA[
var thisLocale Locale.getInstance('da''DK');
//]]>
</script>

?>

Vis: Class methods

Locale, Class methods

Her er 'klasse metoderne' for Locale klassen:

  • __construct
  • getLanguage
  • getCountry
  • getHtml
  • display
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

Locale, Object vars

Her er 'objekt variable' for Locale klassen:

  • html =>
  • sql =>

MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.3.3-7+squeeze9) 1.11
blank.gif