I18N
[ class tree: I18N ] [ index: I18N ] [ all elements ]

Source for file Language.php

Documentation is available at Language.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  4. // +----------------------------------------------------------------------+
  5. // | PHP version 4.0                                                      |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group       |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.0 of the PHP license,       |
  10. // | that is bundled with this package in the file LICENSE, and is        |
  11. // | available at through the world-wide-web at                           |
  12. // | http://www.php.net/license/2_02.txt.                                 |
  13. // | If you did not receive a copy of the PHP license and are unable to   |
  14. // | obtain it through the world-wide-web, please send a note to          |
  15. // | license@php.net so we can mail you a copy immediately.               |
  16. // +----------------------------------------------------------------------+
  17. // | Authors: Naoki Shima <murahachibu@php.net>                           |
  18. // |                                                                      |
  19. // +----------------------------------------------------------------------+//
  20. // $Id: Language.php 110339 2003-01-04 11:55:29Z mj $
  21.  
  22. require_once('I18N/Common.php');
  23.  
  24. class I18N_Language extends I18N_Common {
  25.  
  26.     // {{ constructor
  27.  
  28.     /**
  29.      * Save list of ISO-639-1 two letter language code to language name mapping to its initiating object
  30.      *
  31.      * @return: void
  32.      * @access: public
  33.      */
  34.     function I18N_Language()
  35.     {
  36.         // call constructor of parent class
  37.         parent::_constructor();
  38.  
  39.         /**
  40.          * List of ISO-639-1.
  41.          * Two letter code to Language mapping
  42.          * If you need three letter code to Language mappng,
  43.          * then fetch ISO-639-2
  44.          * @type  : array
  45.          * @access: private
  46.          */
  47.         $this->_codes = array(
  48.             'aa' => 'Afar',
  49.             'ab' => 'Abkhazian',
  50.             'af' => 'Afrikaans',
  51.             'am' => 'Amharic',
  52.             'ar' => 'Arabic',
  53.             'as' => 'Assamese',
  54.             'ay' => 'Aymara',
  55.             'az' => 'Azerbaijani',
  56.             'ba' => 'Bashkir',
  57.             'be' => 'Byelorussian',
  58.             'bg' => 'Bulgarian',
  59.             'bh' => 'Bihari',
  60.             'bi' => 'Bislama',
  61.             'bn' => 'Bengali; Bangla',
  62.             'bo' => 'Tibetan',
  63.             'br' => 'Breton',
  64.             'ca' => 'Catalan',
  65.             'co' => 'Corsican',
  66.             'cs' => 'Czech',
  67.             'cy' => 'Welsh',
  68.             'da' => 'Danish',
  69.             'de' => 'German',
  70.             'dz' => 'Bhutani',
  71.             'el' => 'Greek',
  72.             'en' => 'English',
  73.             'eo' => 'Esperanto',
  74.             'es' => 'Spanish',
  75.             'et' => 'Estonian',
  76.             'eu' => 'Basque',
  77.             'fa' => 'Persian',
  78.             'fi' => 'Finnish',
  79.             'fj' => 'Fiji',
  80.             'fo' => 'Faeroese',
  81.             'fr' => 'French',
  82.             'fy' => 'Frisian',
  83.             'ga' => 'Irish',
  84.             'gd' => 'Scots Gaelic',
  85.             'gl' => 'Galician',
  86.             'gn' => 'Guarani',
  87.             'gu' => 'Gujarati',
  88.             'ha' => 'Hausa',
  89.             'hi' => 'Hindi',
  90.             'hr' => 'Croatian',
  91.             'hu' => 'Hungarian',
  92.             'hy' => 'Armenian',
  93.             'ia' => 'Interlingua',
  94.             'ie' => 'Interlingue',
  95.             'ik' => 'Inupiak',
  96.             'in' => 'Indonesian',
  97.             'is' => 'Icelandic',
  98.             'it' => 'Italian',
  99.             'iw' => 'Hebrew',
  100.             'ja' => 'Japanese',
  101.             'ji' => 'Yiddish',
  102.             'jw' => 'Javanese',
  103.             'ka' => 'Georgian',
  104.             'kk' => 'Kazakh',
  105.             'kl' => 'Greenlandic',
  106.             'km' => 'Cambodian',
  107.             'kn' => 'Kannada',
  108.             'ko' => 'Korean',
  109.             'ks' => 'Kashmiri',
  110.             'ku' => 'Kurdish',
  111.             'ky' => 'Kirghiz',
  112.             'la' => 'Latin',
  113.             'ln' => 'Lingala',
  114.             'lo' => 'Laothian',
  115.             'lt' => 'Lithuanian',
  116.             'lv' => 'Latvian, Lettish',
  117.             'mg' => 'Malagasy',
  118.             'mi' => 'Maori',
  119.             'mk' => 'Macedonian',
  120.             'ml' => 'Malayalam',
  121.             'mn' => 'Mongolian',
  122.             'mo' => 'Moldavian',
  123.             'mr' => 'Marathi',
  124.             'ms' => 'Malay',
  125.             'mt' => 'Maltese',
  126.             'my' => 'Burmese',
  127.             'na' => 'Nauru',
  128.             'ne' => 'Nepali',
  129.             'nl' => 'Dutch',
  130.             'no' => 'Norwegian',
  131.             'oc' => 'Occitan',
  132.             'om' => '(Afan) Oromo',
  133.             'or' => 'Oriya',
  134.             'pa' => 'Punjabi',
  135.             'pl' => 'Polish',
  136.             'ps' => 'Pashto, Pushto',
  137.             'pt' => 'Portuguese',
  138.             'qu' => 'Quechua',
  139.             'rm' => 'Rhaeto-Romance',
  140.             'rn' => 'Kirundi',
  141.             'ro' => 'Romanian',
  142.             'ru' => 'Russian',
  143.             'rw' => 'Kinyarwanda',
  144.             'sa' => 'Sanskrit',
  145.             'sd' => 'Sindhi',
  146.             'sg' => 'Sangro',
  147.             'sh' => 'Serbo-Croatian',
  148.             'si' => 'Singhalese',
  149.             'sk' => 'Slovak',
  150.             'sl' => 'Slovenian',
  151.             'sm' => 'Samoan',
  152.             'sn' => 'Shona',
  153.             'so' => 'Somali',
  154.             'sq' => 'Albanian',
  155.             'sr' => 'Serbian',
  156.             'ss' => 'Siswati',
  157.             'st' => 'Sesotho',
  158.             'su' => 'Sundanese',
  159.             'sv' => 'Swedish',
  160.             'sw' => 'Swahili',
  161.             'ta' => 'Tamil',
  162.             'te' => 'Tegulu',
  163.             'tg' => 'Tajik',
  164.             'th' => 'Thai',
  165.             'ti' => 'Tigrinya',
  166.             'tk' => 'Turkmen',
  167.             'tl' => 'Tagalog',
  168.             'tn' => 'Setswana',
  169.             'to' => 'Tonga',
  170.             'tr' => 'Turkish',
  171.             'ts' => 'Tsonga',
  172.             'tt' => 'Tatar',
  173.             'tw' => 'Twi',
  174.             'uk' => 'Ukrainian',
  175.             'ur' => 'Urdu',
  176.             'uz' => 'Uzbek',
  177.             'vi' => 'Vietnamese',
  178.             'vo' => 'Volapuk',
  179.             'wo' => 'Wolof',
  180.             'xh' => 'Xhosa',
  181.             'yo' => 'Yoruba',
  182.             'zh' => 'Chinese',
  183.             'zu' => 'Zulu'
  184.         );
  185.     }
  186.  
  187.     // }}
  188.     // {{ _constructor()
  189.  
  190.     /**
  191.      * fake constructor. calls actual constructor
  192.      *
  193.      * @return: void
  194.      * @access: private
  195.      *  /
  196.     function _constructor()
  197.     {
  198.         $this->I18N_Language();
  199.     }
  200.  
  201.     // }}
  202.     // {{ _I18N_Language()
  203.  
  204.     /**
  205.      *  destructor. does nothing now.
  206.      *
  207.      * @return: void
  208.      * @access: private
  209.      *  /
  210.     function _I18N_Language()
  211.     {
  212.     }
  213.  
  214.     // }}
  215.     // {{ isValidCode()
  216.  
  217.     /**
  218.      *  Check to see if passed Language code is valid meaning
  219.      *  defined in ISO-639-1.
  220.      * 
  221.      * @param string    Language code to check
  222.      * 
  223.      * @return: boolean
  224.      * @access: public
  225.      *  /
  226.     function isValidCode($code)
  227.     {
  228.         return in_array(strtolower($code),array_keys($this->_codes));
  229.     }
  230.  
  231.     // }}
  232.     // {{ getName()
  233.   
  234.     /**
  235.      *  Return name of the language for language code passed
  236.      * 
  237.      *  @param string     language code
  238.      * 
  239.      *  @return: string     name of the language
  240.      *  @access: public
  241.      */
  242.     function getName($code '')
  243.     {
  244.         if(($code strtolower($code)) && in_array($code,array_keys($this->_codes))) {
  245.             return $this->_codes[$code];
  246.         }
  247.         return FALSE;
  248.     }
  249.  
  250.     // }}
  251. }
  252. ?>

Documentation generated on Mon, 11 Mar 2019 15:36:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.