<?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>Sand&#039;s Lazy Land</title>
	<atom:link href="http://flyingsand.com/sand/feed/" rel="self" type="application/rss+xml" />
	<link>http://flyingsand.com/sand</link>
	<description>Dreaming My Dreams</description>
	<lastBuildDate>Tue, 17 Jan 2012 13:30:08 +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>制作CakePHP语言包（Poedit使用方法）</title>
		<link>http://flyingsand.com/sand/2012/01/17/%e5%88%b6%e4%bd%9ccakephp%e8%af%ad%e8%a8%80%e5%8c%85%ef%bc%88poedit%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95%ef%bc%89/</link>
		<comments>http://flyingsand.com/sand/2012/01/17/%e5%88%b6%e4%bd%9ccakephp%e8%af%ad%e8%a8%80%e5%8c%85%ef%bc%88poedit%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95%ef%bc%89/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 13:23:59 +0000</pubDate>
		<dc:creator>sand</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[poedit]]></category>

		<guid isPermaLink="false">http://flyingsand.com/sand/?p=4</guid>
		<description><![CDATA[CakePHP和许多其它开源程序一样，使用.mo格式的语言包， 先下载并安装poedit：http://www.poedit.net/download.php 先要让poedit用PHP的方式来支持.ctp扩展（CakePHP的View文件）： 打开poedit，工具栏&#62;&#62;文件&#62;&#62;首选； 到“解析器”tab，选中PHP，点“编辑”； 将“列示扩展名……”里设成 *.ctp;*.php ；（注意是分号，不是逗号） 将“解析器命令”里改成 xgettext --language=PHP --force-po -o %o %C %K %F ；（我之前因为采用默认的设置，导致后来无法获取表(报错：warning: file ‘.ctp’ extension ‘ctp’ is unknown; will try C.)，在浪费了半个小时后终于找到这篇文章） 可以动工了，假定CakePHP程序在E:\cakephp\，新建目录： E:\cakephp\app\Locale\zh_cn E:\cakephp\app\Locale\zh_cn\LC_MESSAGES 用poedit新建一个项目，地址为上述LC_MESSAGES目录，文件名为default.po， 项目目录设置里，基本路径为此LC_MESSAGES目录，记得在路径里设为“.”，这代表将搜寻所有子目录，见截图： “关键字”tab里，增加函数__，见截图（可以增加多个函数关键字）： 工具栏&#62;&#62;类目&#62;&#62;从源更新，poedit会查询项目目录里所有php、ctp文件里用到的“__()”函数，将待翻译项罗列出来（如果po文件里某字符串已经翻译好了，该翻译不会被覆盖，如果po文件里某字符串不再存在于项目目录里，则会被删掉）； 恭喜你，可以开始翻译了！（每次保存po文件时，将在相同目录下产生mo语言文件） 关于函数__d及其它 CakePHP里还用到的字符输出函数__d(‘cake’,&#8217;translate me’,&#8217;param’)，表示按“cake”域的语言包来进行翻译，用不同的域有利于我们拆解且方便管理语言包文件，也能让一个字符串在不同情况下可以有不同的翻译，请如上述default一样，在LC_MESSAGES下创建cake.po项目，但因为它采用的函数有别于“__()”，“__d(‘domain’,’translate me‘,’param’)”的待翻译变量是第二个变量，需要在项目设置里，把关键字设成“__d:2”，见下图：]]></description>
			<content:encoded><![CDATA[<p>CakePHP和许多其它开源程序一样，使用.mo格式的语言包，<br />
先下载并安装poedit：<a href="http://www.poedit.net/download.php">http://www.poedit.net/download.php</a></p>
<p>先要让poedit用PHP的方式来支持.ctp扩展（CakePHP的View文件）：</p>
<ol>
<li>打开poedit，工具栏&gt;&gt;文件&gt;&gt;首选；</li>
<li>到“解析器”tab，选中PHP，点“编辑”；</li>
<li>将“列示扩展名……”里设成 <code>*.ctp;*.php</code> ；（注意是分号，不是逗号）</li>
<li>将“解析器命令”里改成 <code>xgettext --language=PHP --force-po -o %o %C %K %F</code> ；（我之前因为采用默认的设置，导致后来无法获取表(报错：warning: file ‘.ctp’ extension ‘ctp’ is unknown; will try C.)，在浪费了半个小时后<a href="http://www.honk.com.au/index.php/2008/10/10/poedit-ctp-is-unknown-will-try-c/">终于找到这篇文章</a>）</li>
</ol>
<p>可以动工了，假定CakePHP程序在E:\cakephp\，新建目录：<br />
E:\cakephp\app\Locale\zh_cn<br />
E:\cakephp\app\Locale\zh_cn\LC_MESSAGES</p>
<p>用poedit新建一个项目，地址为上述LC_MESSAGES目录，文件名为default.po，</p>
<ol>
<li>项目目录设置里，基本路径为此LC_MESSAGES目录，记得在路径里设为“.”，这代表将搜寻所有子目录，见截图：<br />
<a href="http://flyingsand.com/sand/files/2012/01/poedit_01.jpg"><img class="alignnone size-full wp-image-5" title="poedit类目设置（路径）" src="http://flyingsand.com/sand/files/2012/01/poedit_01.jpg" alt="poedit类目设置（路径）" width="322" height="350" /></a></li>
<li>“关键字”tab里，增加函数__，见截图（可以增加多个函数关键字）：<br />
<a href="http://flyingsand.com/sand/files/2012/01/poedit__.jpg"><img class="alignnone size-full wp-image-6" title="poedit：__()" src="http://flyingsand.com/sand/files/2012/01/poedit__.jpg" alt="poedit：__()" width="322" height="350" /></a></li>
<li>工具栏&gt;&gt;类目&gt;&gt;从源更新，poedit会查询项目目录里所有php、ctp文件里用到的“__()”函数，将待翻译项罗列出来（如果po文件里某字符串已经翻译好了，该翻译不会被覆盖，如果po文件里某字符串不再存在于项目目录里，则会被删掉）；</li>
<li>恭喜你，可以开始翻译了！（每次保存po文件时，将在相同目录下产生mo语言文件）</li>
</ol>
<p><strong>关于函数__d及其它</strong></p>
<p>CakePHP里还用到的字符输出函数__d(‘cake’,&#8217;translate me’,&#8217;param’)，表示按“cake”域的语言包来进行翻译，用不同的域有利于我们拆解且方便管理语言包文件，也能让一个字符串在不同情况下可以有不同的翻译，请如上述default一样，在LC_MESSAGES下创建cake.po项目，但因为它采用的函数有别于“__()”，“__d(‘domain’,’translate me‘,’param’)”的待翻译变量是第二个变量，需要在项目设置里，把关键字设成“__d:2”，见下图：</p>
<p><a href="http://flyingsand.com/sand/files/2012/01/poedit__d.jpg"><img class="alignnone size-full wp-image-7" title="poedit：__d()" src="http://flyingsand.com/sand/files/2012/01/poedit__d.jpg" alt="poedit：__d()" width="322" height="350" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flyingsand.com/sand/2012/01/17/%e5%88%b6%e4%bd%9ccakephp%e8%af%ad%e8%a8%80%e5%8c%85%ef%bc%88poedit%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://flyingsand.com/sand/2011/07/04/hello-world/</link>
		<comments>http://flyingsand.com/sand/2011/07/04/hello-world/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 03:34:31 +0000</pubDate>
		<dc:creator>sand</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flyingsand.com/sand/?p=1</guid>
		<description><![CDATA[Welcome to Flying &#038; Sand Sites. This is your first post. Edit or delete it, then start blogging!]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://flyingsand.com/">Flying &#038; Sand Sites</a>. This is your first post. Edit or delete it, then start blogging!</p>
]]></content:encoded>
			<wfw:commentRss>http://flyingsand.com/sand/2011/07/04/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

