Source for file GetTextLocale.php

Documentation is available at GetTextLocale.php

  1. <?php
  2. /**
  3. * Return text based on language and domain name using the php gettext fonction
  4. *
  5. * PHP versions 5
  6. @category  PHP
  7. @package   GeoPrisma
  8. @author    Stephane Guillemette
  9. @author    Pascal Martin
  10. @copyright 2009, Boreal - Information Strategies
  11. @license   http://www.geoprisma.org/license BSD License
  12. @link      http://www.geoprisma.org
  13. */
  14.  
  15. /**
  16. * Return text based on language and domain name using the php gettext fonction
  17. *  
  18. @category   PHP
  19. @package    GeoPrisma
  20. @subpackage UI
  21. @author     Stephane Guillemette
  22. @author     Pascal Martin
  23. */      
  24.   
  25. {
  26.     private static $s_objInstance null;
  27.  
  28.     /**
  29.     * Construit un instance de org_geoprisma_locale_GetTextLocale
  30.     * 
  31.     * @return org_geoprisma_locale_GetTextLocale 
  32.     */   
  33.     private function __construct()
  34.     {
  35.         // Constructeur privĂ© pour forcer l'utilisation de getInstance (Singleton DP)      
  36.         $this->setLanguage($this->getDefaultLanguage());    
  37.     }
  38.     
  39.     /**
  40.     * Retourne un instance de org_geoprisma_locale_GetTextLocale
  41.     * Singleton DP
  42.     * 
  43.     * @return org_geoprisma_locale_GetTextLocale 
  44.     */
  45.     public static function getInstance()
  46.     {
  47.         if (is_null(self::$s_objInstance)) 
  48.         {
  49.             self::$s_objInstance new org_geoprisma_locale_GetTextLocale();
  50.         }
  51.         return self::$s_objInstance;
  52.     }
  53.     
  54.     /**
  55.     * Set the current use langage for traduction (e.g. en_US , fr_CA)
  56.     * 
  57.     * @param string $pstrLanguage Language
  58.     * 
  59.     * @return void 
  60.     */
  61.     public function setLanguage($pstrLanguage)
  62.     {
  63.         parent::setLanguage($pstrLanguage);    
  64.         putenv("LANGUAGE=$pstrLanguage")
  65.         setlocale(LC_ALL$pstrLanguage.".UTF8")
  66.     }
  67.       
  68.     /**
  69.     * Return text based on domainName for right language
  70.     * 
  71.     * @param string $pstrMsg        Message Key
  72.     * @param string $pstrDomainName Name of the
  73.     *
  74.     * @return string 
  75.     */  
  76.     public function getTranslation($pstrMsg$pstrDomainName)
  77.     {        
  78.         com_borealis_foundation_util_Assert::assertIsNotEmptyString($pstrDomainName)
  79.  
  80.         bindtextdomain($pstrDomainNameorg_geoprisma_SettingImpl::getLocaleDir());
  81.         textdomain($pstrDomainName);
  82.  
  83.         bind_textdomain_codeset($pstrDomainName"UTF-8");
  84.         return _($pstrMsg);
  85.     
  86. }
  87. ?>

Documentation generated on Thu, 19 Jan 2012 00:08:34 +0400 by phpDocumentor 1.4.1