gettext l10n.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-04-16 01:56:04 +00:00
parent e5ab2fa0dd
commit e3e0e62cd7
7 changed files with 456 additions and 56 deletions

View File

@ -41,15 +41,15 @@ require('wp-blog-header.php');
<div class="post">
<h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h3>
<div class="meta"><?php $lang->str('filed_under'); ?> <?php the_category() ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
<div class="storycontent">
<?php the_content(); ?>
</div>
<div class="feedback">
<?php link_pages('<br />'.$lang->str('pages','',1).' ', '<br />', 'number'); ?>
<?php comments_popup_link($lang->str('comment_count_0','',1), $lang->str('comment_count_1','',1), $lang->str('comment_count_n','',1)); ?>
<?php link_pages('<br />'. __("Pages:").' ', '<br />', 'number'); ?>
<?php comments_popup_link(__("Comments (0)"), __("Comments (1)"), __("Comments (%)")); ?>
</div>
<!--
@ -60,7 +60,7 @@ require('wp-blog-header.php');
</div>
<?php } } else { // end foreach, end if any posts ?>
<p><?php $lang->str('no_posts_matched'); ?></p>
<p><?php _e("Sorry, no posts matched your criteria."); ?></p>
<?php } ?>
</div>
@ -70,21 +70,21 @@ require('wp-blog-header.php');
<ul>
<?php get_links_list(); ?>
<li id="categories"><?php $lang->str('categories'); ?>
<li id="categories"><?php _e("Categories:"); ?>
<ul>
<?php wp_list_cats(); ?>
</ul>
</li>
<li id="search">
<label for="s"><?php $lang->str('search'); ?></label>
<label for="s"><?php _e("Search:"); ?></label>
<form id="searchform" method="get" action="<?php echo $PHP_SELF; ?>">
<div>
<input type="text" name="s" id="s" size="15" /><br />
<input type="submit" name="submit" value="<?php $lang->str('search_button'); ?>" />
<input type="submit" name="submit" value="<?php _e("search"); ?>" />
</div>
</form>
</li>
<li id="archives"><?php $lang->str('archives'); ?>
<li id="archives"><?php _e("Archives"); ?>
<ul>
<?php get_archives('monthly'); ?>
</ul>
@ -92,18 +92,19 @@ require('wp-blog-header.php');
<li id="calendar">
<?php get_calendar(); ?>
</li>
<li id="other"><?php $lang->str('other'); ?>
<li id="other"><?php _e("Other:"); ?>
<ul>
<li><a href="<?php echo get_settings('siteurl'); ?>/wp-login.php"><?php $lang->str('login'); ?></a></li>
<li><a href="<?php echo get_settings('siteurl'); ?>/wp-register.php"><?php $lang->str('register'); ?></a></li>
<li><a href="<?php echo get_settings('siteurl'); ?>/wp-login.php"><?php _e("Login"); ?></a></li>
<li><a href="<?php echo get_settings('siteurl'); ?>/wp-register.php"><?php _e("Register"); ?></a></li>
</ul>
</li>
<li id="meta"><?php $lang->str('meta'); ?>
<li id="meta"><?php _e("Meta:"); ?>
<ul>
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php $lang->str('rss_2_title'); ?>"><?php $lang->str('rss_2'); ?></a></li>
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php $lang->str('comments_rss_2_title'); ?>"><?php $lang->str('comments_rss_2'); ?></a></li>
<li><a href="http://validator.w3.org/check/referer" title="<?php $lang->str('valid_xhtml_title'); ?>"><?php $lang->str('valid_xhtml'); ?></a></li>
<li><a href="http://wordpress.org" title="<?php $lang->str('powered_by_title'); ?>">WP</a></li>
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e("Syndicate this site using RSS"); ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> 2.0"); ?></a></li>
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e("The latest comments to all posts in RSS"); ?>"><?php _e("Comments <abbr title=\"Really Simple Syndication\">RSS</abbr> 2.0"); ?></a></li>
<li><a href="http://validator.w3.org/check/referer" title="<?php _e("This page validates as XHTML 1.0 Transitional"
); ?>"><?php _e("Valid <abbr title=\"eXtensible HyperText Markup Language\">XHTML</abbr>"); ?></a></li>
<li><a href="http://wordpress.org" title="<?php _e("Powered by WordPress; state-of-the-art semantic personal publishing platform."); ?>">WP</a></li>
</ul>
</li>
@ -113,6 +114,6 @@ require('wp-blog-header.php');
</div>
<p class="credit"><!--<?php echo $wpdb->querycount; ?> queries.--> <?php timer_stop(1); ?> || <?php $lang->str('powered_by_wordpress',$lang->str('powered_by_title','',1)); ?></p>
<p class="credit"><!--<?php echo $wpdb->querycount; ?> queries.--> <?php timer_stop(1); ?> || <cite><?php echo sprintf(__("Powered by <a href=\"http://wordpress.org\" title=\"%s\"><strong>WordPress</strong></a></cite></p>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform")); ?>
</body>
</html>
</html>

View File

@ -8,7 +8,7 @@ foreach ($posts as $post) { start_wp();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo get_settings('blogname'); ?> - <?php $lang->str('comments_on',the_title('','',false)); ?></title>
<title><?php echo get_settings('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" />
<style type="text/css" media="screen">
@ -21,12 +21,12 @@ foreach ($posts as $post) { start_wp();
<h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
<h2 id="comments"><?php $lang->str('comments'); ?></h2>
<h2 id="comments"><?php _e("Comments"); ?></h2>
<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php $lang->str('comments_rss_post'); ?></a></p>
<p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
<?php if ('open' == $post->ping_status) { ?>
<p><?php $lang->str('trackback_uri'); ?> <em><?php trackback_url() ?></em></p>
<p><?php _e("The <acronym title=\"Uniform Resource Identifier\">URI</acronym> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
<?php } ?>
<?php
@ -45,54 +45,54 @@ if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS['wp-postpass_'.$c
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type(); ?> <?php $lang->str('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
<p><cite><?php comment_type(); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
</li>
<?php } // end for each comment ?>
</ol>
<?php } else { // this is displayed if there are no comments so far ?>
<p><?php $lang->str('no_comments'); ?></p>
<p><?php _e("No comments yet."); ?></p>
<?php } ?>
<?php if ('open' == $commentstatus->comment_status) { ?>
<h2><?php $lang->str('leave_a_comment'); ?></h2>
<p><?php $lang->str('comment_instructions'); ?> <code><?php echo allowed_tags(); ?></code></p>
<h2><?php _e("Leave a comment"); ?></h2>
<p><?php _e("Line and paragraph breaks automatic, e-mail address never displayed, <acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"); ?> <code><?php echo allowed_tags(); ?></code></p>
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
<label for="author"><?php $lang->str('comment_name'); ?></label>
<label for="author"><?php _e("Name"); ?></label>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"]); ?>" />
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
<label for="email"><?php $lang->str('comment_email'); ?></label>
<label for="email"><?php _e("E-mail"); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
<label for="url"><?php $lang->str('comment_uri'); ?></label>
<label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>
</p>
<p>
<label for="comment"><?php $lang->str('comment_body'); ?></label>
<label for="comment"><?php _e("Your Comment"); ?></label>
<br />
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<p>
<input name="submit" type="submit" tabindex="5" value="<?php $lang->str('say_it'); ?>" />
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />
</p>
</form>
<?php } else { // comments are closed ?>
<p><?php $lang->str('comments_closed'); ?></p>
<p><?php _e("Sorry, the comment form is closed at this time."); ?></p>
<?php }
} // end password check
?>
<div><strong><a href="javascript:window.close()"><?php $lang->str('close_window'); ?></a></strong></div>
<div><strong><a href="javascript:window.close()"><?php _e("Close this window."); ?></a></strong></div>
<?php // if you delete this the sky will fall on your head
}
@ -100,7 +100,7 @@ if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS['wp-postpass_'.$c
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <?php $lang->str('powered_by_wordpress',$lang->str('powered_by_title','',1)); ?></p>
<p class="credit"><?php timer_stop(1); ?> <?php echo sprintf(__("<cite>Powered by <a href=\"http://wordpress.org\" title=\"%s\"><strong>Wordpress</strong></a></cite>"),__("Powered by WordPress; state-of-the-art semantic personal publishing platform.")); ?></p>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
<!--

View File

@ -6,7 +6,7 @@
if (!empty($post->post_password)) { // if there's a password
if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie
?>
<p><?php $lang->str('comments_password'); ?><p>
<p><?php e_("Enter your password to view comments."); ?><p>
<?php
return;
}
@ -21,13 +21,13 @@
<!-- You can start editing here. -->
<h2 id="comments"><?php comments_number($lang->str('comments','',1)); ?>
<h2 id="comments"><?php comments_number(__("Comments")); ?>
<?php if ('open' == $post->comment_status) { ?>
<a href="#postcomment" title="<?php $lang->str('leave_a_comment'); ?>">&raquo;</a>
<a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
<?php } ?>
</h2>
<?php if ('open' == $post->ping_status) { ?>
<p><?php $lang->str('trackback_uri'); ?> <em><?php trackback_url() ?></em></p>
<p><?php _e("The <acronym title=\"Uniform Resource Identifier\">URI</acronym> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
<?php } ?>
@ -36,49 +36,49 @@
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type(); ?> <?php $lang->str('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link($lang->str('edit_this', '', 1), ' |'); ?></p>
<p><cite><?php comment_type(); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
</li>
<?php } // end for each comment ?>
</ol>
<?php } else { // this is displayed if there are no comments so far ?>
<p><?php $lang->str('no_comments'); ?></p>
<p><?php _e("No comments yet."); ?></p>
<?php } ?>
<p><?php comments_rss_link($lang->str('comments_rss_post', '', 1)); ?></p>
<h2 id="postcomment"><?php $lang->str('leave_a_comment'); ?></h2>
<p><?php comments_rss_link(__("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post.")); ?></p>
<h2 id="postcomment"><?php _e("Leave a comment"); ?></h2>
<?php if ('open' == $post->comment_status) { ?>
<p><?php $lang->str('comments_instructions'); ?> <code><?php echo allowed_tags(); ?></code></p>
<p><?php _e("Line and paragraph breaks automatic, e-mail address never displayed, <acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"); ?> <code><?php echo allowed_tags(); ?></code></p>
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
<label for="author"><?php $lang->str('comment_name'); ?></label>
<label for="author"><?php _e("Name"); ?></label>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"]); ?>" />
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" />
<label for="email"><?php $lang->str('comment_email'); ?></label>
<label for="email"><?php _e("E-mail"); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
<label for="url"><?php $lang->str('comment_uri'); ?></label>
<label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>
</p>
<p>
<label for="comment"><?php $lang->str('comment_body'); ?></label>
<label for="comment"><?php _e("Your Comment"); ?></label>
<br />
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<p>
<input name="submit" type="submit" tabindex="5" value="<?php $lang->str('say_it'); ?>" />
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />
</p>
</form>
<?php } else { // comments are closed ?>
<p><?php $lang->str('comments_closed'); ?></p>
<p><?php _e("Sorry, the comment form is closed at this time."); ?></p>
<?php } ?>
<?php // if you delete this the sky will fall on your head

232
wp-includes/gettext.php Executable file
View File

@ -0,0 +1,232 @@
<?php
/*
Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// For start, we only want to read the MO files
class gettext_reader {
//public:
var $error = 0; // public variable that holds error code (0 if no error)
//private:
var $BYTEORDER = 0;
var $STREAM = NULL;
var $short_circuit = false;
function readint() {
// Reads 4 byte value from $FD and puts it in int
// $BYTEORDER specifies the byte order: 0 low endian, 1 big endian
for ($i=0; $i<4; $i++) {
$byte[$i]=ord($this->STREAM->read(1));
}
//print sprintf("pos: %d\n",$this->STREAM->currentpos());
if ($this->BYTEORDER == 0)
return (int)(($byte[0]) | ($byte[1]<<8) | ($byte[2]<<16) | ($byte[3]<<24));
else
return (int)(($byte[3]) | ($byte[2]<<8) | ($byte[1]<<16) | ($byte[0]<<24));
}
// constructor that requires StreamReader object
function gettext_reader($Reader) {
// If there isn't a StreamReader, turn on short circuit mode.
if (! $Reader) {
$this->short_circuit = true;
return;
}
$MAGIC1 = (int)0x950412de;
$MAGIC2 = (int)0xde120495;
$this->STREAM = $Reader;
$magic = $this->readint();
if ($magic == $MAGIC1) {
$this->BYTEORDER = 0;
} elseif ($magic == $MAGIC2) {
$this->BYTEORDER = 1;
} else {
$this->error = 1; // not MO file
return false;
}
// FIXME: Do we care about revision? We should.
$revision = $this->readint();
$total = $this->readint();
$originals = $this->readint();
$translations = $this->readint();
$this->total = $total;
$this->originals = $originals;
$this->translations = $translations;
}
function load_tables($translations=false) {
// if tables are loaded do not load them again
if (!is_array($this->ORIGINALS)) {
$this->ORIGINALS = array();
$this->STREAM->seekto($this->originals);
for ($i=0; $i<$this->total; $i++) {
$len = $this->readint();
$ofs = $this->readint();
$this->ORIGINALS[] = array($len,$ofs);
}
}
// similar for translations
if ($translations and !is_array($this->TRANSLATIONS)) {
$this->TRANSLATIONS = array();
$this->STREAM->seekto($this->translations);
for ($i=0; $i<$this->total; $i++) {
$len = $this->readint();
$ofs = $this->readint();
$this->TRANSLATIONS[] = array($len,$ofs);
}
}
}
function get_string_number($num) {
// get a string with particular number
// TODO: Add simple hashing [check array, add if not already there]
$this->load_tables();
$meta = $this->ORIGINALS[$num];
$length = $meta[0];
$offset = $meta[1];
$this->STREAM->seekto($offset);
$data = $this->STREAM->read($length);
return (string)$data;
}
function get_translation_number($num) {
// get a string with particular number
// TODO: Add simple hashing [check array, add if not already there]
$this->load_tables(true);
$meta = $this->TRANSLATIONS[$num];
$length = $meta[0];
$offset = $meta[1];
$this->STREAM->seekto($offset);
$data = $this->STREAM->read($length);
return (string)$data;
}
// binary search for string
function find_string($string, $start,$end) {
//print "start: $start, end: $end\n";
if (abs($start-$end)<=1) {
// we're done, if it's not it, bye bye
$txt = $this->get_string_number($start);
if ($string == $txt)
return $start;
else
return -1;
} elseif ($start>$end) {
return $this->find_string($string,$end,$start);
} else {
$half = (int)(($start+$end)/2);
$tst = $this->get_string_number($half);
$cmp = strcmp($string,$tst);
if ($cmp == 0)
return $half;
elseif ($cmp<0)
return $this->find_string($string,$start,$half);
else
return $this->find_string($string,$half,$end);
}
}
function translate($string) {
if ($this->short_circuit) {
return $string;
}
$num = $this->find_string($string, 0, $this->total);
if ($num == -1)
return $string;
else
return $this->get_translation_number($num);
}
function get_plural_forms() {
// lets assume message number 0 is header
// this is true, right?
// cache header field for plural forms
if (is_string($this->pluralheader))
return $this->pluralheader;
else {
$header = $this->get_translation_number(0);
if (eregi("plural-forms: (.*)\n",$header,$regs)) {
$expr = $regs[1];
} else {
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
}
$this->pluralheader = $expr;
return $expr;
}
}
function select_string($n) {
$string = $this->get_plural_forms();
$string = str_replace('nplurals',"\$total",$string);
$string = str_replace("n",$n,$string);
$string = str_replace('plural',"\$plural",$string);
$total = 0;
$plural = 0;
eval("$string");
if ($plural>=$total) $plural = 0;
return $plural;
}
function ngettext($single, $plural, $number) {
if ($this->short_circuit) {
if ($number != 1) return $plural;
else return $single;
}
// find out the appropriate form
$select = $this->select_string($number);
// this should contains all strings separated by NULLs
$result = $this->find_string($single.chr(0).$plural,0,$this->total);
if ($result == -1) {
if ($number != 1) return $plural;
else return $single;
} else {
$result = $this->get_translation_number($result);
// lets try to parse all the NUL staff
//$result = "proba0".chr(0)."proba1".chr(0)."proba2";
$list = explode (chr(0), $result);
return $list[$select];
}
}
}
?>

133
wp-includes/streams.php Executable file
View File

@ -0,0 +1,133 @@
<?php
/*
Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Simple class to wrap file streams, string streams, etc.
// seek is essential, and it should be byte stream
class StreamReader {
// should return a string [FIXME: perhaps return array of bytes?]
function read($bytes) {
return false;
}
// should return new position
function seekto($position) {
return false;
}
// returns current position
function currentpos() {
return false;
}
// returns length of entire stream (limit for seekto()s)
function length() {
return false;
}
}
class StringReader {
var $_pos;
var $_str;
function StringReader($str='') {
$this->_str = $str;
$this->_pos = 0;
}
function read($bytes) {
$data = substr($this->_str, $this->_pos, $bytes);
$this->_pos += $bytes;
if (strlen($this->_str)<$this->_pos)
$this->_pos = strlen($this->_str);
return $data;
}
function seekto($pos) {
$this->_pos = $pos;
if (strlen($this->_str)<$this->_pos)
$this->_pos = strlen($this->_str);
return $this->_pos;
}
function currentpos() {
return $this->_pos;
}
function length() {
return strlen($this->_str);
}
}
class FileReader {
var $_pos;
var $_fd;
var $_length;
function FileReader($filename) {
if (file_exists($filename)) {
$this->_length=filesize($filename);
$this->_pos = 0;
$this->_fd = fopen($filename,'rb');
if (!$this->_fd) {
$this->error = 3; // Cannot read file, probably permissions
return false;
}
} else {
$this->error = 2; // File doesn't exist
return false;
}
}
function read($bytes) {
fseek($this->_fd, $this->_pos);
$data = fread($this->_fd, $bytes);
$this->_pos = ftell($this->_fd);
return $data;
}
function seekto($pos) {
fseek($this->_fd, $pos);
$this->_pos = ftell($this->_fd);
return $this->_pos;
}
function currentpos() {
return $this->_pos;
}
function length() {
return $this->_length;
}
function close() {
fclose($this->_fd);
}
}
?>

39
wp-includes/wp-l10n.php Normal file
View File

@ -0,0 +1,39 @@
<?php
$curpath = dirname(__FILE__).'/';
// The locale is hard-coded here for now.
$locale = 'en_GB';
$mofile = $curpath . "/languages/$locale.mo";
require($curpath . 'streams.php');
require($curpath . 'gettext.php');
// If the mo file does not exist or is not readable, or if the locale is
// en_US, do not load the mo.
if ( is_readable($mofile) && ($locale != 'en_US') ) {
$input = new FileReader($mofile);
} else {
$input = false;
}
$l10n = new gettext_reader($input);
// Return a translated string.
function __($text) {
global $l10n;
return $l10n->translate($text);
}
// Echo a translated string.
function _e($text) {
global $l10n;
echo $l10n->translate($text);
}
// Return the plural form.
function __ngettext($single, $plural, $number) {
global $l10n;
return $l10n->ngettext($single, $plural, $number);
}
?>

View File

@ -42,7 +42,7 @@ require_once (ABSPATH . WPINC . '/class-xmlrpc.php');
require_once (ABSPATH . WPINC . '/class-xmlrpcs.php');
require_once (ABSPATH . WPINC . '/links.php');
require_once (ABSPATH . WPINC . '/kses.php');
require_once (ABSPATH . WPINC . '/class-language.php');
require_once (ABSPATH . WPINC . '/wp-l10n.php');
//setup the old globals from b2config.php
//
@ -76,9 +76,4 @@ if (!strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && get_settings('ac
include(ABSPATH . 'wp-content/plugins/' . $plugin);
}
}
// temporarily hardcoded, AK
require_once (ABSPATH . WPINC . '/languages/english.php');
?>
?>