ShareTronix 的汉化笔记
by 尘缘 on 四月 27th, 2010 // Filed Under → sharetronix
本笔记借鉴了张永生大哥的资料,这里表示感谢.
ShareTronix 是一款国外的微博程序,汉化的过程基本上都要经历以下步骤.
注:本版本使用ST 1.4.0版,其它版本可能有所不同,其中,C为控制器Controllers的简称。
一,中文用户名支持
- 用户注册限制:
文件:Controllers/signup.php,行204if( !$D->error && preg_match('/[^a-z0-9-_]/i', $D->username) ) {改成
if( !$D->error && preg_match('/[^a-z0-9-_\x{4e00}-\x{9fa5}]/iu', $D->username) ) { - 对应增加对中文用户空间的支持:
文件:classes/class_page_php,行41$request = $_SERVER['REQUEST_URI'];
修改为:
$request = urldecode($_SERVER['REQUEST_URI']);
文件:classes/class_page_php,行104/109
preg_match('/^([a-z0-9\-_]+)两处中文用户名匹配均修改为:
preg_match('/^([a-z0-9\-_\x{4e00}-\x{9fa5}]+) - 对应增加主题@中文用户支持:
文件classes/Class_newpost.php,行109if( preg_match_all('/\@([a-zA-Z0-9\-_]{3,30})/u', $message, $matches, PREG_PATTERN_ORDER) ) {改成
if( preg_match_all('/\@([a-zA-Z0-9\-_\x{4e00}-\x{9fa5}]{3,30})/u', $message, $matches, PREG_PATTERN_ORDER) ) { - 对应增加评论@中文用户支持:
文件classes/Class_newpostcomment.php,行78if( preg_match_all('/\@([a-zA-Z0-9\-_]{3,30})/u', $message, $matches, PREG_PATTERN_ORDER) ) {改成
if( preg_match_all('/\@([a-zA-Z0-9\-_\x{4e00}-\x{9fa5}]{3,30})/u', $message, $matches, PREG_PATTERN_ORDER) ) { - 对应增加中文标签的支持:
文件classes/Class_newpost.php,行179
文件classes/Class_newpostcomment.php,行88
同样增加 \x{4e00}-\x{9fa5},因为代码里有易乱码字符,这里不贴出来了。 - 对应增加中文RSS支持:
文件controllers/rss.php,行118$u = $this->network->get_user_by_username($this->param('username'));修改成
$u = $this->network->get_user_by_username(urldecode($this->param('username')));
二,中文用户体验优化和SEO优化
- 用户空间优化
Controllers/user.php 行19$D->page_title = $u->username.' - '.$C->SITE_TITLE;
改为
$D->page_title = $u->username.'的微博 - '.$C->SITE_TITLE;
- theme/html/settings_profile.php,行41左右
调整年月日顺序 - theme/html/settings_contacts.php,删除不用的联系信息,并添加QQ表单
C/settings_contacts.php,添加入库字段
D/users_details添加qq字段
三,后台功能优化
- 增加底部版权信息
C/admin_general.php,行64行,$D->power_by = isset($C->POWER_BY) ? trim($C->POWER_BY) : '';
C/admin_general.php,133行,
$D->power_by = isset($_POST['power_by']) ? trim($_POST['power_by']) : ''; $C->LANGUAGE == '4wei' && $db2->query('REPLACE INTO settings SET word="POWER_BY", value="'.$db2->e($D->power_by).'" ');V/admin_general.php,行96行,
<?php if(isset($D->power_by)) {?> <tr> <td valign="top"><?= $this->lang('admgnrl_frm_powerby') ?></td> <td><textarea name="power_by" style="height:100px;"><?= stripslashes($D->power_by) ?></textarea></td> </tr> <?php }?>
你可以任意转摘“ShareTronix 的汉化笔记”,但请保留本文出处和版权信息。
作者:尘缘,QQ:130775,来源:http://www.4wei.cn/archives/1000578

有 1 条评论啦
Posted on 2010年08月18号 at 21:44:49
Mercury :
你好~ 本文提到了theme/html/settings_profile.php,行41左右
调整年月日顺序排列调整,请问阁下 对应的 _m 是英文的,我不知道如何修改变成中文 一月 二月 等 谢谢回复。
走过路过,千万不要飞过,那是鸟人: