ShareTronix 的汉化笔记

本笔记借鉴了张永生大哥的资料,这里表示感谢.

ShareTronix 是一款国外的微博程序,汉化的过程基本上都要经历以下步骤.

注:本版本使用ST 1.4.0版,其它版本可能有所不同,其中,C为控制器Controllers的简称。

一,中文用户名支持

  1. 用户注册限制:
    文件:Controllers/signup.php,行204
    [php]if( !$D->error && preg_match(‘/[^a-z0-9-_]/i’, $D->username) ) {[/php]

    改成

    [php]if( !$D->error && preg_match(‘/[^a-z0-9-_\x{4e00}-\x{9fa5}]/iu’, $D->username) ) {[/php]

  2. 对应增加对中文用户空间的支持:
    文件:classes/class_page_php,行41
    [php]$request    = $_SERVER[‘REQUEST_URI’];[/php]

    修改为:

    [php]$request    = urldecode($_SERVER[‘REQUEST_URI’]);[/php]

    文件:classes/class_page_php,行104/109

    [php]preg_match(‘/^([a-z0-9\-_]+)[/php]

    两处中文用户名匹配均修改为:

    [php]preg_match(‘/^([a-z0-9\-_\x{4e00}-\x{9fa5}]+)[/php]

  3. 对应增加主题@中文用户支持:
    文件classes/Class_newpost.php,行109
    [php]if( preg_match_all(‘/\@([a-zA-Z0-9\-_]{3,30})/u’, $message, $matches, PREG_PATTERN_ORDER) ) {[/php]

    改成

    [php]if( preg_match_all(‘/\@([a-zA-Z0-9\-_\x{4e00}-\x{9fa5}]{3,30})/u’, $message, $matches, PREG_PATTERN_ORDER) ) {[/php]

  4. 对应增加评论@中文用户支持:
    文件classes/Class_newpostcomment.php,行78
    [php]if( preg_match_all(‘/\@([a-zA-Z0-9\-_]{3,30})/u’, $message, $matches, PREG_PATTERN_ORDER) ) {[/php]

    改成

    [php]if( preg_match_all(‘/\@([a-zA-Z0-9\-_\x{4e00}-\x{9fa5}]{3,30})/u’, $message, $matches, PREG_PATTERN_ORDER) ) {[/php]

  5. 对应增加中文标签的支持:
    文件classes/Class_newpost.php,行179
    文件classes/Class_newpostcomment.php,行88
    同样增加 \x{4e00}-\x{9fa5},因为代码里有易乱码字符,这里不贴出来了。
  6. 对应增加中文RSS支持:
    文件controllers/rss.php,行118
    [php]$u    = $this->network->get_user_by_username($this->param(‘username’));[/php]

    修改成

    [php]$u    = $this->network->get_user_by_username(urldecode($this->param(‘username’)));[/php]

二,中文用户体验优化和SEO优化

  1. 用户空间优化
    Controllers/user.php 行19
    [php]$D->page_title    = $u->username.’ – ‘.$C->SITE_TITLE;[/php]

    改为

    [php]$D->page_title    = $u->username.’的微博 – ‘.$C->SITE_TITLE;[/php]

  2. theme/html/settings_profile.php,行41左右
    调整年月日顺序
  3. theme/html/settings_contacts.php,删除不用的联系信息,并添加QQ表单
    C/settings_contacts.php,添加入库字段
    D/users_details添加qq字段

三,后台功能优化

  1. 增加底部版权信息
    C/admin_general.php,行64行,[php]$D->power_by    = isset($C->POWER_BY) ? trim($C->POWER_BY) : ”;[/php]

    C/admin_general.php,133行,

    [php]$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).’" ‘);[/php]

    V/admin_general.php,行96行,

    [php]<?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 }?>[/php]

发表评论

评论列表(1)

  • Mercury

    2010.8.18 21:08

    你好~ 本文提到了theme/html/settings_profile.php,行41左右
    调整年月日顺序排列调整,请问阁下 对应的 _m 是英文的,我不知道如何修改变成中文 一月 二月 等 谢谢回复。

    回复