note 99983 added to book.gettext

From: Date: Fri, 17 Sep 2010 20:10:45 +0000
Subject: note 99983 added to book.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-172701@lists.php.net to get a copy of this message
I wrote a simple i18n class for this: http://github.com/c9s/i18n.php <?php class I18N { protected $cur_lang = array(); protected $a_langs = array(); function init( $force_lang = null ) { $lang = null; if( $force_lang ) { $lang = $force_lang; } else if( @$_REQUEST['lang'] ) { $lang = $_REQUEST['lang']; } else if( isset( $_COOKIE['lang'] ) ) { $lang = $_COOKIE['lang']; } if( ! $lang ) { $lang = DEF_LANG; } $this->speak( $lang ); } // set current language function speak( $lang ) { $this->cur_lang = $lang; setcookie("lang", $lang , 0 ); } function is_speaking() { return $this->cur_lang; } // get available language list function langs() { return $this->a_langs; } function set_list( $list ) { $this->a_langs = $list; } function add( $lang , $name ) { $this->a_langs[ $lang ] = $name; } function remove( $lang ) { unset( $this->a_langs[ $lang ] ); } // get language name from language hash function name( $lang ) { return @$this->a_langs[ $lang ]; } function gettext( $textdomain , $localdir = null ) { $lang = $this->cur_lang; putenv("LANG=$lang"); setlocale(LC_MESSAGES, $lang ); if( $localdir == null ) $localdir = dirname(__FILE__) . '/' . 'locale'; bindtextdomain( $textdomain, $localdir ); bind_textdomain_codeset( $textdomain, 'UTF-8'); textdomain( $textdomain ); } } function i18n() { global $i18n; if( $i18n == null ) { $i18n = new I18N(); init_i18n( $i18n ); } return $i18n; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 113.61.199.42 ---- Manual Page -- http://www.php.net/manual/en/book.gettext.php Edit -- https://master.php.net/note/edit/99983 Del: integrated -- https://master.php.net/note/delete/99983/integrated Del: useless -- https://master.php.net/note/delete/99983/useless Del: bad code -- https://master.php.net/note/delete/99983/bad+code Del: spam -- https://master.php.net/note/delete/99983/spam Del: non-english -- https://master.php.net/note/delete/99983/non-english Del: in docs -- https://master.php.net/note/delete/99983/in+docs Del: other reasons-- https://master.php.net/note/delete/99983 Reject -- https://master.php.net/note/reject/99983 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172701) next »