Source for file i18n.php

Documentation is available at i18n.php

  1. <?php
  2. /**
  3. * Internationali[sz]ation of Bumblebee
  4. *
  5. * Loads language pack for Bumblebee and tools for translating strings.
  6. * Makes use of PHP's gettext() functions if they are available
  7. * and the locale is installed on the server and can be found.
  8. * Since this is rarely the case, particularly on shared servers,
  9. * the fallback has to be a good one.
  10. *
  11. * The php-gettext project provides the base functionality required.
  12. *
  13. * See
  14. *        http://savannah.nongnu.org/projects/php-gettext/
  15. *
  16. * (tested with php-gettext version 1.0.7)
  17. *
  18. @author    Stuart Prescott
  19. @copyright  Copyright Stuart Prescott
  20. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  21. @version    $Id$
  22. @package    Bumblebee
  23. @subpackage Misc
  24. */
  25.  
  26. /** Load ancillary functions */
  27. require_once 'inc/typeinfo.php';
  28.  
  29. require_once 'inc/bb/configreader.php';
  30.  
  31. /** php-gettext base file for gettext emulation */
  32. include_once 'php-gettext/gettext.inc';
  33. /** logging routine */
  34. require_once 'inc/logging.php';
  35.  
  36. // get PHP to send a UTF-8 header for the content-type charset rather
  37. // than the PHP4 default iso8859-1
  38. ini_set('default_charset''utf-8');
  39.  
  40. $conf ConfigReader::getInstance();
  41.  
  42. // As of PHP5.0, we *must* set the timezone for date calculations, otherwise
  43. // many errors will be emitted. For a list of timezones, see
  44. //     http://php.net/manual/en/timezones.php
  45. $tz $conf->value('language''timezone''Europe/London');
  46.  
  47. // this could be done per-user, but that would be more difficult...
  48. //$locale = (isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE;
  49. $locale $conf->value('language''locale');
  50.  
  51. // work out if php-gettext is installed on this system
  52. if (function_exists('T_setlocale'&& function_exists('T_')) {
  53.   //it is
  54.     $encoding 'UTF-8';
  55.   /** package name for i18n (mo name) */
  56.   define('PACKAGE''bumblebee');
  57.  
  58.  
  59.   // gettext setup
  60.     T_setlocale(LC_MESSAGES$locale);
  61.  
  62.   T_bindtextdomain(PACKAGE$conf->value('language''translation_base'));
  63.   T_bind_textdomain_codeset(PACKAGE$encoding);
  64.   T_textdomain(PACKAGE);
  65.  
  66.   if (!locale_emulation()) {
  67.     logmsg(9"using C gettext for locale '$locale'");
  68.   }
  69.   else {
  70.     logmsg(9"emulating gettext for locale '$locale'");
  71.   }
  72. else {
  73.   // php gettext not installed
  74.     logmsg(9"Cannot find php-gettext so ignoring request for locale '$locale'");
  75.   function T_($sreturn $s}
  76. }
  77.  
  78. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:34 +0000 by phpDocumentor 1.3.0