<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>笨猫&#039;s Blog &#187; theme</title>
	<atom:link href="http://www.benmao.com/archives/tag/theme/feed" rel="self" type="application/rss+xml" />
	<link>http://www.benmao.com</link>
	<description>关注互联网，生活，音乐，乐此不疲的一只笨猫</description>
	<lastBuildDate>Tue, 07 Feb 2012 13:18:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>针对新手的wordpress theme汉化教程</title>
		<link>http://www.benmao.com/archives/306</link>
		<comments>http://www.benmao.com/archives/306#comments</comments>
		<pubDate>Fri, 05 Dec 2008 12:15:06 +0000</pubDate>
		<dc:creator>笨猫</dc:creator>
				<category><![CDATA[猫玩技术]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.benmao.com/?p=306</guid>
		<description><![CDATA[我第一次使用sandbox框架制作wordpress theme，想把theme汉化成中文版的，如果一个个文件去编辑相当麻烦… 之前也有看到某些网友的博客有发布某某皮肤汉化包等~ 我就想了，应该所有的wp theme都可以汉化的吧~于是便开始动手… 在网上查阅了很多资料~也问了很多朋友，，，最后终于明白制作theme汉化包的方法…不敢独享，，，发布上来供那些和我一样新接触wordpress的朋友参阅！我想无论是你自己制作theme还是看上了国外某个theme，这个教程都将对你有所帮助！ 虽然网上制作theme语言包的方法别人介绍过，但大多讲的比较笼统，对于刚接触wp的朋友来说还得花上不少时间去消化！该教程主要针对初级用户写的初级教程,图文并茂！ 首先配置你的wordpress theme! 在theme中把需要汉化的地方使用如下格式设置好： &#60;?php _e('需要汉化的内容在这里', 'c2cer') ?&#62; 上面的c2cer这个是可以根据你自己的皮肤名字来定的！ 例如我的theme叫做:popdo 然后我要汉化的语句是：one comment 那么就可以写成： &#60;?php _e('one comment', 'popdo') ?&#62; 如果要翻译的语句与php数据库有查询关系（不知道说的对不对，暂且这么说吧），那么调用的时候就要用__()而不是_e()的方式，例如： &#60;?php the_excerpt('Read More ?')?&#62; 那么格式就可以写成： &#60;?php the_excerpt( __( 'Read More ?' ,'popdo') )?&#62; 如果上面让你不知所云的话~你也可以下载一套sandbox的框架查看里面的语句。都设置好这些后，在theme的functions.php文件中的最下面添加一句： &#60;?php add_action ('init','my_theme_init'); function my_theme_init () { load_theme_textdomain ('popdo'); } &#62; 上面的(’popdo’)要与你原先设置的名字要一致，最好直接使用theme的名字！ 这样theme上的工作都完成了~ 接下来开始poedit上的汉化步骤： 首先下载一个Poedit（PoEdit是一款Windows下的.po文件编辑器，常用来汉化各种程序），安装好后~启动软件，点击：文件—新建消息目录文档。在弹出的对话框中出现如下设置： 工程名称以及版本：填写你的工程名称 [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F1322&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">WordPress风格各异的图标</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F1498&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">WordPress 3.X代码实现关闭程序、主题、插件更新提示</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F33&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">有道推出相关博文推荐WordPress插件</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F105&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">Christmas’ WordPress Theme(圣诞主题收集)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F324&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">汇总：我使用的WordPress插件 [2008.06.30]</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>我第一次使用sandbox框架制作wordpress <a href="http://www.benmao.com/archives/tag/theme" class="st_tag internal_tag" rel="tag" title="标签 theme 下的日志">theme</a>，想把theme汉化成中文版的，如果一个个文件去编辑相当麻烦…</p>
<p>之前也有看到某些网友的博客有发布某某皮肤汉化包等~<br />
我就想了，应该所有的wp theme都可以汉化的吧~于是便开始动手…</p>
<p>在网上查阅了很多资料~也问了很多朋友，，，最后终于明白制作theme汉化包的方法…不敢独享，，，发布上来供那些和我一样新接触wordpress的朋友参阅！我想无论是你自己制作theme还是看上了国外某个theme，这个教程都将对你有所帮助！</p>
<p>虽然网上制作theme语言包的方法别人介绍过，但大多讲的比较笼统，对于刚接触wp的朋友来说还得花上不少时间去消化！该教程主要针对初级用户写的初级教程,图文并茂！</p>
<p><strong>首先配置你的wordpress theme!</strong></p>
<p>在theme中把需要汉化的地方使用如下格式设置好：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="font-weight: bold; color: #000000;">&lt;?php</span> _e<span style="color: #009900;">(</span><span>'需要汉化的内容在这里'</span><span style="color: #339933;">,</span> <span>'c2cer'</span><span style="color: #009900;">)</span> <span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
</div>
</div>
<p>上面的c2cer这个是可以根据你自己的皮肤名字来定的！</p>
<p>例如我的theme叫做:popdo 然后我要汉化的语句是：one comment</p>
<p>那么就可以写成：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="font-weight: bold; color: #000000;">&lt;?php</span> _e<span style="color: #009900;">(</span><span>'one comment'</span><span style="color: #339933;">,</span> <span>'popdo'</span><span style="color: #009900;">)</span> <span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
</div>
</div>
<p>如果要翻译的语句与php数据库有查询关系（不知道说的对不对，暂且这么说吧），那么调用的时候就要用__()而不是_e()的方式，例如：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="font-weight: bold; color: #000000;">&lt;?php</span> the_excerpt<span style="color: #009900;">(</span><span>'Read More  ?'</span><span style="color: #009900;">)</span><span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
</div>
</div>
<p>那么格式就可以写成：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="font-weight: bold; color: #000000;">&lt;?php</span> the_excerpt<span style="color: #009900;">(</span> __<span style="color: #009900;">(</span> <span>'Read More  ?'</span> <span style="color: #339933;">,</span><span>'popdo'</span><span style="color: #009900;">)</span> <span style="color: #009900;">)</span><span style="font-weight: bold; color: #000000;">?&gt;</span></pre>
</div>
</div>
<p>如果上面让你不知所云的话~你也可以下载一套<a href="http://www.plaintxt.org/themes/sandbox/" target="_blank"><span style="color: #4d5d2c;">sandbox</span></a>的框架查看里面的语句。都设置好这些后，在theme的functions.php文件中的最下面添加一句：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="font-weight: bold; color: #000000;">&lt;?php</span>
add_action <span style="color: #009900;">(</span><span>'init'</span><span style="color: #339933;">,</span><span>'my_theme_init'</span><span style="color: #009900;">)</span>;
<span style="font-weight: bold; color: #000000;">function</span> my_theme_init <span style="color: #009900;">(</span><span style="color: #009900;">)</span>
<span style="color: #009900;">{</span>
load_theme_textdomain <span style="color: #009900;">(</span><span>'popdo'</span><span style="color: #009900;">)</span>;
<span style="color: #009900;">}</span>
<span style="color: #339933;">&gt;</span></pre>
</div>
</div>
<p>上面的(’popdo’)要与你原先设置的名字要一致，最好直接使用theme的名字！</p>
<p>这样theme上的工作都完成了~</p>
<p><strong>接下来开始poedit上的汉化步骤：</strong></p>
<p>首先下载一个<a href="http://www.poedit.net/" target="_blank"><span style="color: #4d5d2c;">Poedit</span></a>（PoEdit是一款Windows下的.po文件编辑器，常用来汉化各种程序），安装好后~启动软件，点击：文件—新建消息目录文档。在弹出的对话框中出现如下设置：</p>
<p>工程名称以及版本：<span style="color: #808080;">填写你的工程名称<br />
</span>团队： <span style="color: #808080;">你的团队</span><br />
团队专用电子邮件：<span style="color: #808080;">你的Email<br />
</span>语言：<span style="color: #808080;">你的国家语言</span><br />
国家：<span style="color: #808080;">你的国家</span><br />
字符集：<span style="color: #808080;">建议utf-8<br />
</span>源代码字符集：<span style="color: #808080;">建议utf-8</span><br />
复数形式： <span style="color: #808080;">留空</span></p>
<p><span style="color: #808080;"><span style="color: #000000;">如图：<br />
<img class="alignnone size-full wp-image-58" title="poedit" src="http://www.c2cer.com/wp-content/uploads/2008/12/1.gif" alt="poedit" width="288" height="277" /><br />
</span></span><span style="color: #808080;"><span style="color: #000000;"><br />
路径的设置用一个”.”(点号)-即同级目录以及该目录下的所有子目录：<br />
<a href="http://www.c2cer.com/wp-content/uploads/2008/12/2.gif" target="_blank"><img class="alignnone size-full wp-image-59" title="poedit2" src="http://www.c2cer.com/wp-content/uploads/2008/12/2.gif" alt="poedit2" width="288" height="277" /></a></span></span></p>
<p><span style="color: #808080;"><span style="color: #000000;">因为路径的问题鼓捣了半天~吸取教训了！</span></span></p>
<p><span style="color: #808080;"><span style="color: #000000;">之前theme里设置了汉化的内容关联了_e和__，所以关键字设置如下：<br />
<a href="http://www.c2cer.com/wp-content/uploads/2008/12/3.gif" target="_blank"><img class="alignnone size-full wp-image-60" title="poedit3" src="http://www.c2cer.com/wp-content/uploads/2008/12/3.gif" alt="poedit3" width="288" height="277" /></a></span></span></p>
<p><span style="color: #993300;">然后点确定，跳出.po文件保存对话框，将.po文件起名为zh_CN.po保存在theme的根目录下（之前设置了路径为”.” ，所以这里保存位置很关键！）</span></p>
<p>保存之后就自动弹出待翻译的所有语句列表，确定之后就可以开始翻译了，未翻译的语句会显示蓝色粗体字，在列表下面有两个输入框，上面一个框是待翻译语句，下面一个框是你的翻译内容！</p>
<p><a href="http://www.c2cer.com/wp-content/uploads/2008/12/4.gif" target="_blank"><img class="alignnone size-full wp-image-61" title="poedit4" src="http://www.c2cer.com/wp-content/uploads/2008/12/4.gif" alt="poedit4" width="336" height="412" /></a></p>
<p>poedit中翻译好后Ctrl+s保存，会自动生成.mo文件，翻译工作完成后还差最后一步，别急！</p>
<p>打开你的wordpress根目录下的文件wp-config.php</p>
<p>查找语句：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="color: #990000;">define</span> <span style="color: #009900;">(</span><span>'WPLANG'</span><span style="color: #339933;">,</span> <span>''</span><span style="color: #009900;">)</span>;</pre>
</div>
</div>
<p>将其改为：</p>
<div class="wp_syntax">
<div class="code">
<pre class="php php" style="font-family: monospace;"><span style="color: #990000;">define</span> <span style="color: #009900;">(</span><span>'WPLANG'</span><span style="color: #339933;">,</span> <span>'zh_CN'</span><span style="color: #009900;">)</span>;</pre>
</div>
</div>
<p>保存，刷新你的wordpress首页，恭喜你看到了熟悉的国语！</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F1322&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">WordPress风格各异的图标</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F1498&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">WordPress 3.X代码实现关闭程序、主题、插件更新提示</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F33&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">有道推出相关博文推荐WordPress插件</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F105&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">Christmas’ WordPress Theme(圣诞主题收集)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.benmao.com%2Farchives%2F324&from=http%3A%2F%2Fwww.benmao.com%2Farchives%2F306">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 14px !important;">汇总：我使用的WordPress插件 [2008.06.30]</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.benmao.com/archives/306/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

