Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial language class as a wrapper for using phpgettext as a class a…
…nd reading .mo files directly. git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2014 b72ed6b6-b9f8-46b5-92b4-906544132732
- Loading branch information
David Olivier
committed
Aug 23, 2006
1 parent
54289fc
commit 9e0eb9d
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/* Wrapper to use phpgettext as a class and omit having an english translation | ||
USAGE: | ||
require_once(dirname(__FILE__).'classes/core/language.php'); | ||
$locale = new phpsurveyor_lang('en'); // Char code | ||
print $locale->getTranslation("Hello World!"); | ||
*/ | ||
|
||
require_once(dirname(__FILE__).'/classes/php-gettext/gettext.php'); | ||
require_once(dirname(__FILE__).'/classes/php-gettext/streams.php'); | ||
|
||
class phpsurveyor_lang { | ||
|
||
var $gettextclass; | ||
|
||
function phpsurveyor_lang($langcode){ | ||
if ( $langcode != "en" ) { | ||
$streamer = new FileReader(dirname(__FILE__).'/locale/'.$langcode.'/LC_MESSAGES/'.$langcode.'.mo'); | ||
$this->gettextclass = new gettext_reader($streamer); | ||
} else { | ||
$this->gettextclass = false; | ||
} | ||
} | ||
|
||
function getTranslation($string) | ||
{ | ||
if ($this->gettextclass) | ||
{ | ||
return $this->gettextclass->translate($string); | ||
} else { | ||
return $string; | ||
} | ||
} | ||
|
||
} | ||
|
||
?> |