分享

plog 汉化使用手记

 Ralf_Jones 2006-11-16
plog 汉化使用手记
[ 2005-09-22 14:58 | 作者: coolsky ]
字体: | |
作为多用户blog系统,plog具有强大的影响力,最近我也拿plog用了一下
顺便记录一下使用过程中要注意的问题
1.汉化
目前版本是1.0.1
Plog程序结构非常好,不过也难以看懂和进行修改。
plog发行版本已经申明不会出GB2312的版本,只有UTF-8
这个问题也困扰了我很久,老外怎么就喜欢用连中国人都不懂的编码呢
不过要与国际接轨 还真得用utf-8
我不喜欢utf-8 所以我把它汉化为GB2312了

其实plog的汉化非常简单 记事本就有这个功能
./locale/locale_zh_CN.php是中文语言包 使用utf-8编码
把它打开 复制所有内容到记事本中 然后另存为文件覆盖locale_zh_CN.php
这时文件大小将由54K 减小到47K 这个文件就是Gb2312的语言包了
别慌 还有一个地方没改
打开这个文件 找到$messages[‘encoding‘]一行 将"utf-8" 替换为gb2312就可以了
汉化完毕

2.配置二级域名
使用者都希望能让申请blog的用户拥有xx.xx.cn这样的二级域名以代替原来又臭又长的一大串参数
1)首先要配置您自己的域名使它支持泛域名解析
所谓泛域名解析是DNS域名提供商提供的一种服务,
您可以使用*. 都能解析到您所在的服务器IP地址
你可以通过自己配置DNS服务器或者向供应商要求这种服务 一般是需要另外加费用的
2)登陆到plog后台控制中心->常规设置->subdomains_enabled 这个选项 将他启用
同时设置好您base_url地址和subdomains_base_url
以我为例:
base_url http://www./blog
subdomains_base_url http://{username}.
这里的username是plog内的一种变量 设置为username 就可以采用用户名为二级域名
如果你设置为{blogid} 那么二级域名就是blogid的值
3)设置url
在URL设置里面选择"自定义链接" 我不采用plog自带的mod rewrite方式
我自己定义基本格式
我设置为

request_format_mode : /archive/{year}/{month}/{day}/{blogid}/{postid}.html$
category_link_format: /categories/{blogid}/{catid}$
archive_link_format : /archive/{blogid}/{year}{month}{day}
user_posts_link_format :/{blogname}/user/{username}$
post_trackbacks_link_format :/{blogname}/post/trackbacks/{postname}$

其他的我还没来得及改 就拿这么多说明吧
以上格式顾名思义了
下面还要在apache的httpd.conf中配置mod rewrite
我不推荐plog自带的.htaccess方式 那样对服务器负担比较大 不过虚拟主机支持的话
也只能用.htaccess方式
我以虚拟主机来说明

<VirtualHost 61.152.114.86>
DocumentRoot /usr/etc/wwwroot/www./blog
ServerAdmin coolsky@
ServerName *.
ServerSignature email
DirectoryIndex summary.php index.php index.html index.htm default.php

RewriteEngine On

#RewriteMap blog txt:/usr/etc/wwwroot/www./blog/blog_url.txt
#RewriteCond %{REQUEST_URI} ^/$
#RewriteCond %{HTTP_HOST} ^([^.]+).$ [NC]
#RewriteCond ${blog:%1} ^(.*)$ [NC]
#RewriteRule ^/(.*)$ %1/$1

RewriteRule ^/archive/[^.]+/[^.]+/[^.]+/([0-9]+)/([0-9]+)+\.html$ /index.php?op=ViewArticle&blogId=$1&articleId=$2

[L,NC]

# Category view (i.e. /plog/88_userfoo/categories/4_cat-foobar.html)
RewriteRule ^/categories/([0-9]+)/([0-9]+)$ /index.php?op=Default&blogId=$1&postCategoryId=$2 [L,NC]
RewriteRule ^/test.html$ /test.php[L,NC]

# Monthly archive (i.e. /plog/1_userfoo/archive/200401.html)
#RewriteRule ^/([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ /index.php?blogId=$1&Date=$2 [L,NC]

# Daily and Month archive (i.e. /plog/1_blogfoo/archive/20040101.html)
RewriteRule ^/archive/([0-9]+)/([0-9]+)$ /index.php?blogId=$1&Date=$2 [L,NC]

#文章归档
RewriteRule ^/([0-9]+)/$ /index.php?op=Template&blogId=$1&show=archives [L,NC]

# Album (i.e. /plog/88_userfoo/albums/34_title-foo-bar.html)
RewriteRule ^/([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html$ /index.php?op=ViewAlbum&blogId=$1&albumId=$2 [L,NC]

# Albums (i.e. /plog/88_userfoo/albums/)
RewriteRule ^/([0-9]+)_[^/]+/albums/$ /index.php?op=ViewAlbum&blogId=$1&albumId=0 [L,NC]


# Category-Feeds (i.e. /plog/3_userfoo/feeds/categories/2_category/atom)
RewriteRule ^/([0-9]+)_[^/]+/feeds/categories/([0-9]+)_[^.]+/(.*)$ /rss.php?blogId=$1&categoryId=$2&profile=$3 [L,NC]

# Feeds (i.e. /plog/3_userfoo/feeds/atom)
RewriteRule ^/([0-9]+)_[^/]+/feeds/(.*)$ /rss.php?blogId=$1&profile=$2 [L,NC]

# Trackbacks (i.e. /plog/3_userfoo/trackbacks/34_title-foo-bar.html)
RewriteRule ^/([0-9]+)_[^/]+/trackbacks/([0-9]+)_[^.]+\.html$ /index.php?op=Trackbacks&blogId=$1&articleId=$2 [L,NC]

# Comment form (i.e. /plog/88_userfoo/comment/34_title-foo-bar.html)
RewriteRule ^/([0-9]+)_[^/]+/comment/([0-9]+)_[^.]+\.html$ /index.php?op=Comment&blogId=$1&articleId=$2 [L,NC]

# Resources (i.e. /plog/88_userfoo/resources/this-is-a-resource-name.pdf.html)
RewriteRule ^/([0-9]+)_[^/]+/resources/([^.]+)\.([^.]+)\.html$ /index.php?op=ViewResource&blogId=$1&resource=$2.$3

[L,NC]

# Download a resource (i.e. /plog/88_userfoo/get/this-is-a-resource-name.pdf)
RewriteRule ^/([0-9]+)_[^/]+/get/(.+)$ /resserver.php?blogId=$1&resource=$2 [L,NC]

# Static Pages (i.e /plog/3_userfoo/demosites)
RewriteRule ^/([0-9]+)_[^/]+/(.+)$ /index.php?op=Template&blogId=$1&show=$2 [NC]

# A non-default blog (i.e. /plog/88_userfoo)
RewriteRule ^/([0-9]+)_[^/]+$ /index.php?blogId=$1 [L,NC]

# Daly archive (i.e. /plog/1_userfoo/archive/20040101.html)
RewriteRule ^/([0-9]+)_[^/]+/archive/([0-9]{8})\.html$ /index.php?blogId=$1&Date=$2 [L,NC]
</VirtualHost>

上面代码下面部分采用了plog的.htaccess文件中默认的,我只改了和修改url对应的部分
以上配置好以后 我们只需要重启apache 你就会发现
如果你申请了名字为coolsky的用户 你就可以用coolsky.这个域名进行访问了
如果你发的文章id是1 那么你文章的链接就会是"http://coolsky./archive/2005/09/14/18/1.html" 的格式
其他类似

这样还不行 如果你输入www.他也会自动转到这个地址上 不是我们的初衷
要保留www.,blog.的域名 我们还需要在apache配置一个虚拟主机
在上面的配置文件下面加上
<VirtualHost 61.152.114.86>
DocumentRoot /usr/etc/wwwroot/www./
ServerAdmin coolsky@
ServerName www.
ServerSignature email
DirectoryIndex summary.php index.html index.htm default.php
</VirtualHost>

这样我们可以用http://www./blog/summary.php来访问首页
如何才能把summary.php设置为首页呢,也就是说
但是当我输入http://blog.的时候是转向是index.php 而不是summary.php
虽然在上面的第一个虚拟主机配置中我们定义了DirectoryIndex summary.php 但是实际却没有起作用
解决方法:
其实我没找到很好的方法
我在index.php中加入以下代码进行转向:

if($_SERVER[‘HTTP_HOST‘]=="blog."){
header(‘location: http://www./blog/‘);
}


4.其他备注
系统默认是要发邮件 确认后才开通的
修改成既时开通方法:
邮件设置->check_email_address_validity 和email_service_enabled 都改为否
另外如果要整合数据库 可以通过外部提交到注册页面的第二步或第三步 并用post模拟原始提交post数据.
[本日志最后由coolsky于2006-02-14 16:35编辑]
引用通告地址:
GB2312 http:///trackback.php?id=133&encode=gb2312
UTF-8    http:///trackback.php?id=133&encode=utf-8
Big5       http:///trackback.php?id=133&encode=big5
游客
[2005-11-04 06:44:41 AM ]
写的真不错。谢谢!
游客
[2005-12-20 09:49:53 AM ]
你好,网上好像只有你这里讲得最详细,想请教。
我是合租的服务器,也只能用.htaccess方式吧,用的是APACHE1.3.33,装Plog 1.0.2 beta,.htaccess的前面好像和你的不同,是这样:
<Files .htaccess>
deny from all
</Files>

<Files config.properties.php>
deny from all
</Files>

Options -Indexes
Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /plog/

# Permalink to the blog entry (i.e. /plog/1_userfoo/archive/3_title-foo-bar.html)
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]+)_[^.]+\.html$ index.php?op=ViewArticle&blogId=$1&articleId=$2 [L,NC]

# Monthly archive (i.e. /plog/1_userfoo/archive/200401.html)
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ index.php?blogId=$1&Date=$2 [L,NC]
。。。
我该怎么修改呢?多谢指点!!
davidx
[2005-12-20 10:15:59 AM ]
续前:忘了说清楚我的目的是配置PLOG二级域名,你这里的1、2步我已完成,第3步URL设置也有点不清楚,可以只把第一项request_format_mode改为Apache Modrewrite,而其他不动吗?其他项的值都类似/blog/{blogname}/{catname}/{year}/{month}/{day}/{postname}$,而我是把Plog系统装在plog目录里,这里的/blog/都应改成/plog/么?
改.htaccess应该是第四步吧?
谢谢!!
管理员回复于 2006-11-16 01:58:33 AM
如果只把第一项request_format_mode改为Apache Modrewrite 那么格式是plog内定的
最好改用:自定义链接 然后可以自定义那个类似/blog/{blogname}/{catname}/{year}/{month}/{day}/{postname}$目录
对于你的目录确实应该把blog改为plog
修改.htaccess对应的是http.conf修改的那一步 基本上是一致的

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约