久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

Gallery: 本地化:修訂間差異

來(lái)自站長(zhǎng)百科
跳轉(zhuǎn)至: 導(dǎo)航、? 搜索
(新頁(yè)面: = Localizing Gallery 2 = == Overview == Gallery is internationalized. Instead of containing language specific text messages, it tracks text in a special way so that it can be extracted...)
?
無(wú)編輯摘要
?
(未顯示同一用戶的4個(gè)中間版本)
第1行: 第1行:
= Localizing Gallery 2 =
= Gallery2的本地化 =


== Overview ==
== 綜述 ==


Gallery is internationalized.? Instead of containing language specific
Gallery是國(guó)際化的。不對(duì)特定語(yǔ)言文本消息的包含,
text messages, it tracks text in a special way so that it can be
取而代之地,它使用特殊的方法追蹤文本
extracted and translated into other languages.? Users will see a
以進(jìn)行抽取并翻譯成其他語(yǔ)言。用戶則會(huì)看見(jiàn)
version of the text that has been converted into their own language.
文本被翻譯成他們使用的語(yǔ)言版本。


In order for the users to see a localized version of Gallery's text,
為了能夠讓用戶看到Gallery文本的本地化版本,
somebody must first translate the text messages that Gallery is going
就需要先將這些Gallery要顯示的文本消息進(jìn)行
to display.? This process is called "localization".
翻譯。此過(guò)程就被稱為"本地化"


Here we try to outline how you can create and maintain localization
這里我們嘗試說(shuō)明一下如何創(chuàng)建并維護(hù)G2中本地化
files for the content in G2.? It's not a particularly difficult thing
文件的內(nèi)容。這并不是特別困難的任務(wù),
to do but it requires us to keep the various files up to date whenever
但要求無(wú)論何時(shí)基礎(chǔ)內(nèi)容有改變,我們都要保證
the underlying content changes.? Luckily we have tools that will aid
各類文件的更新度。我們挺幸運(yùn)的,因?yàn)橛羞@樣的工具能
in this process.
協(xié)助我們完成此類操作過(guò)程。


== Requirements ==
== 要求 ==


In order to really do this effectively, you need to have a few tools
為了能夠有效率地進(jìn)行,你需要在計(jì)算機(jī)上
installed on your machine.? I've only tested this process on a FreeBSD
安裝一些工具。我僅在FreeBSD
box, but my guess is that you won't have too much difficulty on Linux,
box中做了測(cè)試,但我想如果用在Linux,Solaris或其他Unix類系統(tǒng)
Solaris, or other Unix variants.? You may have difficulties following
上也不會(huì)太麻煩。在Windows上可能會(huì)有些難度,
along on Windows, but it should be possible.
但也是有可能實(shí)現(xiàn)的。
The following should be installed and in your PATH:
以下為必須安裝,并在你的路徑中:


; gettext : http://www.gnu.org/software/gettext/
; gettext : http://www.gnu.org/software/gettext/
; gmake (or make): http://www.gnu.org/software/make/make.html
; gmake (或make): http://www.gnu.org/software/make/make.html
; php binary : http://php.net
; php二進(jìn)制: http://php.net
; perl : http://perl.com
; perl : http://perl.com


'''Note''': if you're using FreeBSD then you want to use ''gmake'' instead of ''make'' since FreeBSD's default make is not GNU compatible.
'''''':如果你使用FreeBSD,并希望能取代''make''而使用''gmake'',因?yàn)镕reeBSD的默認(rèn)不與GNU兼容。


You also need the current G2 files to create up-to-date translations.? It is best to work from current SVN or a nightly snapshot.? The developer version of the latest G2 release will also work, but some of the strings for translation may be out of date.
你還需要用當(dāng)前G2文件創(chuàng)建最新的翻譯。就目前的SVN或nightly快照版的運(yùn)行情況都不錯(cuò)。最新的G2開(kāi)發(fā)者版本也能運(yùn)行,但某些翻譯的字串可能有些過(guò)時(shí)了。


== Creating a new localization ==
== 本地化的新建 ==


Look around the Gallery distribution and you'll find a bunch of directories called "po".? ("po" is a gettext term that stands for "portable object").? Here's one way to find them:
瀏覽一下Gallery就能發(fā)現(xiàn)不少名為"po"的目錄。("po"是一gettext術(shù)語(yǔ),即"可移植對(duì)象(portable object)")。以下為找到它們的一個(gè)方法:


<pre>
<pre>
find . -type d -name po <-- you type this
find . -type d -name po <-- 輸入這個(gè)


./themes/matrix/po ? ? ? ? ? <-- you see this
./themes/matrix/po ? ? ? ? ? <-- 會(huì)看到這個(gè)
./lib/tools/po
./lib/tools/po
./modules/core/po
./modules/core/po
第49行: 第49行:
./modules/netpbm/po
./modules/netpbm/po


** Ignore the "lib/tools/po" directory.
** 忽略"lib/tools/po"目錄。
</pre>
</pre>


These directories contain translation source files.? You're going to
這些目錄還有翻譯源文件。你要
create new files with an appropriate language code, and then fill them
使用合適的語(yǔ)言代碼來(lái)新建文件,接著在它們之中
with translated text.? The first thing to do is to identify the
添入經(jīng)過(guò)翻譯的文本。首先要做的就是從
correct codes from the following two tables:
下面的兩個(gè)表格中識(shí)別出正確的代碼:


; Language codes:
; 語(yǔ)言代碼:
: http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC221
: http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC221
: (or http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt)
: (or http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt)


; Country codes:
; 國(guó)家代碼:
: http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC222
: http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC222
: (or http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html)
: (or http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html)


In most cases you will need just the language code, such as "de" for German.? To provide country specific translations for a language used in multiple countries you can use a code in the format xx_XX, such as "pt_BR" for Portuguese/Brazil.? If you are unsure which to use, include both language and country.? If you find a translation for your language already exists then move on to [[#Maintaining_a_localization|Maintaining a localization]].
在大多數(shù)情況下,你只需要語(yǔ)言代碼即可,如德語(yǔ)就是"de"。要為多個(gè)國(guó)家中提供特定國(guó)家語(yǔ)言的翻譯,你可以使用這樣的代碼格式,xx_XX,例如"pt_BR"表示葡萄牙語(yǔ)/巴西。如果你確定該用哪一個(gè),包括語(yǔ)言和國(guó)家。如果你發(fā)現(xiàn)已有你使用語(yǔ)言的翻譯的話,請(qǐng)接著看 [[#本地化的維護(hù)|本地化的維護(hù)]]。


Once you've chosen the code, you need to create a new .po file for
一旦選好了代碼,就需要為你的代碼新建一個(gè).po
your code.? Let's assume that you chose "de".? For each po directory,
文件。假定你選擇是的"de"。那么對(duì)各po目錄,
you need to do this:
你需要做的是:


<pre>
<pre>
第75行: 第75行:
</pre>
</pre>


This will find all text that is marked for localization ([[Gallery2:Tpl_Reference#Gallery_Custom_Tags|{g->text}]] in tpl files, translate() or i18n() in php code) and create a po file that is ready to be translated.
這將找到該本地化標(biāo)記的所有文本(tpl文件中的[[Gallery:Tpl_Reference#Gallery_Custom_Tags|{g->text}]],php代碼中的translate()或i18n()),并創(chuàng)建一個(gè)即將進(jìn)行翻譯的po文件。


A word about text editors.
有關(guān)文本編輯器。
* There are several tools to work with .po files:
* 有一些工具可以處理.po文件:
** [http://poedit.sourceforge.net/ poEdit] (Multiplatform)
** [http://poedit.sourceforge.net/ poEdit](多平臺(tái))
** [http://i18n.kde.org/tools/kbabel/ KBabel] (Unix KDE)
** [http://i18n.kde.org/tools/kbabel/ KBabel](Unix KDE)
** [http://gtranslator.sourceforge.net/ GTranslator] (Unix Gnome)
** [http://gtranslator.sourceforge.net/ GTranslator](Unix Gnome)
** [http://www.gnu.org/software/emacs/emacs.html Emacs with po-mode] (Multiplatform)
** [http://www.gnu.org/software/emacs/emacs.html Emacs with po-mode](多平臺(tái))
** [http://www.vim.org/ Vim] with [http://www.vim.org/scripts/script.php?script_id=695 PO plug-in] (Multiplatform)
** [http://www.vim.org/ Vim] with [http://www.vim.org/scripts/script.php?script_id=695 PO plug-in](多平臺(tái))
I personally am a fan of XEmacs so I'll be
我比較喜歡用XEmacs,因此我會(huì)
talking about XEmacs in my examples below.? If you have instructions for
在下面的例子中拿XEmacs做例子。如果你有其他編輯器
other editors, please contribute them.? XEmacs has a major mode called "po-mode" which, if you have it installed, you'll automatically wind up
的使用指導(dǎo),請(qǐng)分享一下。XEmacs的主要模式被稱為"po-模式",如果你安裝了它,在編輯.po文件時(shí)就會(huì)
in if you edit a .po file.? I'm not going to go into it here, but try
自動(dòng)轉(zhuǎn)入。我在這里不準(zhǔn)備這么做,但
it out if you have it.
你可以嘗試一下。


Now edit de.po.? It should have the Gallery license at the top.? You'll need to customize these values:
現(xiàn)在我們來(lái)編輯de.po。在其頂部應(yīng)有Gallery的證書。你需要對(duì)以下值做自定義:


; Last-Translator
; Last-Translator
: Put your name and email here in the format: "FirstName LastName &lt;email@address&gt;"
:將你的名字及email以此格式輸入:"FirstName LastName &lt;email@address&gt;"
; Language-Team
; Language-Team
: Put in the language and the -translations mailing list, eg: "German &lt;gallery-translations@lists.sourceforge.net&gt;"
: 輸入語(yǔ)言及-翻譯郵件列表,如"German &lt;gallery-translations@lists.sourceforge.net&gt;"
; Content-Type
; Content-Type
: Set this to "Content-Type: text/plain; charset=UTF-8\n"
: 將此設(shè)置給"Content-Type:text/plain; charset=UTF-8\n"
: We want you to use the UTF-8 character set because it allows us to render multiple languages on the same page which is nice for sites in one language that have user comments, etc in other languages.
: 我們希望你使用UTF-8字符集。因?yàn)樗试S我們?cè)谕豁?yè)面上對(duì)多個(gè)語(yǔ)言進(jìn)行渲染,這對(duì)某一語(yǔ)言站點(diǎn)頁(yè)面上其他語(yǔ)言的用戶評(píng)論是有好處的。


Here's an example of a complete header from [http://cvs.sourceforge.net/viewcvs.py/gallery/gallery2/modules/core/po/de.po?rev=1.13&view=auto modules/core/po/de.po].? Note how the authors have maintained the list of all previous translators as a courtesy.
這里有[http://cvs.sourceforge.net/viewcvs.py/gallery/gallery2/modules/core/po/de.po?rev=1.13&view=auto modules/core/po/de.po]的完整的header樣例。注意編寫者是如何維護(hù)前任翻譯者名單的。
<pre>
<pre>
# Previous translators (as far as known, add yourself here, please):
# 前任翻譯者(迄今所知,如有脫漏,請(qǐng)?jiān)诖颂砑樱?/ins>
# - Jens Tkotz <jens@peino.de>
# - Jens Tkotz <jens@peino.de>
# - Ernesto Baschny <ernst@baschny.de>
# - Ernesto Baschny <ernst@baschny.de>
第120行: 第120行:
</pre>
</pre>


If your language doesn't have plural form like in Chinese or Turkish, you need to change the following line too:
如果你的語(yǔ)言中不包含復(fù)數(shù)詞用法,如漢語(yǔ)或土耳其語(yǔ),就得修改以下語(yǔ)句:


<pre>
<pre>
第126行: 第126行:
?? ? -> Change to "Plural-Forms: nplurals=1; plural=0;\n".
?? ? -> Change to "Plural-Forms: nplurals=1; plural=0;\n".
</pre>
</pre>
In this case, you need to translate only msgstr[0] and comment out or remove msgstr[1].
這樣,你只需翻譯msgstr[0]并注釋掉或移除msgstr [1].


Then, look at the lines just below the Gallery license:
接著來(lái)看看Gallery證書下的語(yǔ)句行:


<pre>
<pre>
第136行: 第136行:
</pre>
</pre>


The fuzzy keyword tells you that the translation of the block is
模糊的關(guān)鍵詞告知你區(qū)塊的翻譯
incomplete. But once that you update the administration entries, you
不完整。但一旦更新了administration entry,就
can remove the "#, fuzzy" line to allow the translation to compile
可以移除"#, fuzzy"這一行以允許稍后翻譯的
later on.
編譯。


Next, you'll see a series of blocks like this:
接下來(lái)你會(huì)看到一系列區(qū)塊:


<pre>
<pre>
#, c-format (<-- you'll only see this on some lines)
#, c-format (<-- 在某些語(yǔ)句行中僅能看到這個(gè))
msgid "a message in english, with %d or %s tags in it"
msgid "a message in english, with %d or %s tags in it"
msgstr ""
msgstr ""
</pre>
</pre>


You need to put the translation for the English message into the
你需要將英語(yǔ)消息的翻譯置入
msgstr block, between the quotes, for example:
msgstr區(qū)塊中,用引號(hào)括起來(lái),例如:


<pre>
<pre>
第158行: 第158行:
</pre>
</pre>


Some msgid values contain hints to assist in translation:
某些msgid值含有有助于進(jìn)行翻譯的提示信息:


<pre>
<pre>
第165行: 第165行:
msgstr "F"
msgstr "F"
</pre>
</pre>
Note that the hint should not be translated or included in the msgstr text.? You can request the addition of hint text for particular strings with the [http://sourceforge.net/tracker/?func=browse&group_id=7130&atid=582564 Translations Tracker].? Specify the module/theme and the msgid.? Note that the <tt>strings.raw</tt> file lists the file(s) where each msgid is used.
注意提示內(nèi)容不應(yīng)翻譯或包括在msgstr文本中。你可以使用[http://sourceforge.net/tracker/?func=browse&group_id=7130&atid=582564 翻譯追蹤器(Translations Tracker)]為特殊字串請(qǐng)求額外的提示文本。指定模塊/外觀主題以及msgid。注意<tt>strings.raw</tt>文件列出了用到msgid的文件。


You really, really, really should put your editor into UTF-8 mode
在編輯這些消息之前,你確實(shí)應(yīng)當(dāng)將編輯器設(shè)為UTF-8模式,
before editing these messages so that your editor can use the right
這樣編輯器才能使用正確的字符集。
character set.? If you can't edit in UTF-8 for some reason, consider
如果你由于某種原因無(wú)法在UTF-8模式中進(jìn)行編輯,
using the GNU "recode" program to convert your translation to UTF-8
請(qǐng)考慮使用GNU的"recode"程序,在提交翻譯內(nèi)容給我們之前,
before submitting it to us (or just send it anyway and we'll recode
將其轉(zhuǎn)為UTF-8(或者直接發(fā)給我們也許,我們會(huì)進(jìn)行重新編碼)。
it).


If you're using XEmacs with MULE (its MULtilanguagE support) you can
如果你使用XEmacs的MULE(即多語(yǔ)言支持(MULtilanguagE)),你可以將一下內(nèi)容添加到
add the following to your ~/.xemacs/init.el
~/.xemacs/init.el中去


<pre>
<pre>
第185行: 第184行:
</pre>
</pre>


Then when you edit a file that is in UTF-8, it'll have a little "u"
當(dāng)你編輯UTF-8的文件時(shí),會(huì)有一些"u"
in left side of the status bar at the bottom of the screen.? Try it
出現(xiàn)在屏幕底部狀態(tài)條左側(cè)。使用現(xiàn)有的
out with an existing .po file to see what it looks like.
.po文件來(lái)看一看。


After doing a few translations, try it out to see how it looks.? Run:
在進(jìn)行一些翻譯之后,來(lái)看看效果。運(yùn)行:


<pre>
<pre>
第195行: 第194行:
</pre>
</pre>


And it will compile your .po file into a .mo file and install it in the appropriate place for the module. Repeat this for every directory where you modified a .po file.? If you get errors about creating the locale directory then try creating the directory structure before running make (example: modules/mymodule/locale/de/LC_MESSAGES).
它會(huì)將你的.po文件編譯到一個(gè).mo文件中,并將其安裝到合適的位置。在修改.po文件之后,對(duì)各目錄都要重復(fù)此步驟。如果你在創(chuàng)建locale目錄時(shí)發(fā)生錯(cuò)誤,請(qǐng)?jiān)谶\(yùn)行make之前建立目錄結(jié)構(gòu)(如:modules/mymodule/locale/de/LC_MESSAGES)。


Finally, you need to edit modules/core/classes/GalleryTranslator.class and in function getLanguageData, add lines like this:
最后,你需要編輯modules/core/classes/GalleryTranslator.class,并在函數(shù)getLanguageData中加入如下語(yǔ)句:


<pre>
<pre>
第204行: 第203行:
$defaultCountry['de'] = 'DE';
$defaultCountry['de'] = 'DE';
</pre>
</pre>
The comment should be the name of the language in English; the language
批注應(yīng)為該語(yǔ)言的英語(yǔ)說(shuō)法;語(yǔ)言
'description' is the name of the language in that language.
'描述'則應(yīng)是該語(yǔ)言的本土說(shuō)法。


Now, log onto G2 and in the User preferences (you may need to edit the
現(xiàn)在登入G2,在用戶偏好(你可能需要
user via the Site Administrator) you should see German appear in the
通過(guò)站點(diǎn)管理對(duì)用戶進(jìn)行編輯)中,你應(yīng)能在下拉列表中看到
dropdown, and if you select it and log on as that user you'll see your
German。而如果你選擇了它,并以剛才那個(gè)用戶的身份登入的話,
translated messages.? Alternatively, add the Language selector block
就能看到消息被翻譯為該語(yǔ)言了。你還可以將語(yǔ)言選擇器區(qū)塊
to your site using Theme settings.
添加到站點(diǎn)中,使用外觀主題設(shè)定就可以做到。


'''Note:''' If the language change doesn't take effect, please review the precedence of the [[Gallery2:Language_Settings|language settings]] (Session language > user preferences > site wide default language). In doubt, use the language block or toggle the language in your user preferences back and forth.
'''注:''' 如果語(yǔ)言修改沒(méi)有起效,請(qǐng)回顧一下[[Gallery:Language_Settings|語(yǔ)言設(shè)定]]的優(yōu)先級(jí)(會(huì)話語(yǔ)言(Session language) > 用戶偏好(user preferences) > 站點(diǎn)范圍的默認(rèn)語(yǔ)言(site wide default language))。如果有疑慮的話,可以使用語(yǔ)言區(qū)塊或在用戶偏好中反復(fù)嘗試。


== Submitting your localization ==
== 本地化的提交 ==


Now that you've got your localization created, you need to package
現(xiàn)在本地化就應(yīng)創(chuàng)建號(hào)了,你需要將其
it up and send it to us so that we can commit it into the repository.
打包并發(fā)送給我們,這樣我們就能將其添入存儲(chǔ)庫(kù)。
The best way to package it is like this:
最好的打包方式如下:


<pre>
<pre>
第232行: 第231行:
</pre>
</pre>


This will make up a zipfile or tarball of just your translated files.? Obviously, use your language code instead of de or nl above.? Then, go to the [http://sourceforge.net/tracker/?func=browse&group_id=7130&atid=582564 Translations Tracker] on the Gallery project page on SourceForge and click the "Submit New" button.? Put your translation in the "Gallery 2" group and don't forget to attach the files (you must check the checkbox for attachment too!).? If your translation doesn't
你翻譯過(guò)的文件會(huì)被做成zipfile或tarball。當(dāng)然使用你自己的語(yǔ)言代碼取代上面的de或nl。接著瀏覽SourceForge 的Gallery項(xiàng)目頁(yè)面上的[http://sourceforge.net/tracker/?func=browse&group_id=7130&atid=582564 翻譯追蹤器]并點(diǎn)擊"Submit New"按鈕。將你的翻譯放入"Gallery 2"組中,并將文件加入附件上傳。如果你的翻譯
get committed within a few days, jump on IRC (see [[#Where_to_go_for_help!|help section]]) and talk to us about it.
過(guò)了幾天還沒(méi)有被采用的話,請(qǐng)上IRC(參見(jiàn)[[#Where_to_go_for_help!|幫助部分]])告知我們。


== Maintaining a localization ==
== 本地化的維護(hù) ==


<pre>
<pre>
第242行: 第241行:
</pre>
</pre>


This will extract all messages from the module that you're in and
這會(huì)從你所在的模塊中提取出所有消息
update the .po file. Look through the .po file for any blocks that
并更新.po文件。瀏覽.po文件,找到所有具有
have an empty msgstr, or are marked "fuzzy" and update them.? After
空msgstr或被標(biāo)記為"模糊(fuzzy)"的區(qū)塊并更新它們。在它們
they are fixed, remove the fuzzy tag.? You may find tags that look
被修復(fù)之后,移除fuzzy標(biāo)識(shí)。你看到的標(biāo)識(shí)會(huì)是如下的
like this:
樣子:


<pre>
<pre>
第254行: 第253行:
</pre>
</pre>


The "#, fuzzy" means that its fuzzy, but the "#~" means that the
"#, fuzzy"表示它是模糊的,但"#~"表明該
string no longer exists in G2 (we probably deleted or changed it
字串不存在于G2中(我們可能將其刪除或修改了
significantly).? You can delete these entries.
)。你可以刪除這些內(nèi)容.


You should do a quick check that gettext provides to validate your .po file:
你應(yīng)當(dāng)快速地做一次gettext提供的檢查,以驗(yàn)證.po文件:
? msgfmt -v -c --stat de.po
? msgfmt -v -c --stat de.po


When you've got everything right, run:
當(dāng)一切都設(shè)置好后,運(yùn)行:


<pre>
<pre>
第267行: 第266行:
</pre>
</pre>


The translation files get cached by PHP (which is why it's so fast)
翻譯文件被PHP緩存(這就是其快速的原因)
so you may not see change until you restart your web server.? That's
因此在重啟web服務(wù)器之前,可能無(wú)法看到所作的修改。這是
annoying, but I haven't figured a good workaround for it yet.
有點(diǎn)麻煩,但我還沒(méi)有想出好的解決辦法。


See the [[#Creating_a_new_localization|Creating a new localization]] section for testing info, and submit the new files to us.
參見(jiàn)[[#本地化的新建]|本地化的新建]]部分的測(cè)試信息,并向我們提交新文件。


== Where to go for help! ==
== 何處尋求幫助?==


If you need help, there are three places to go:
如果你需要幫助,有三個(gè)地方可以求助:


; The Gallery translations forums:
; The Gallery translations forums:
第286行: 第285行:
: #gallery on irc://chat.freenode.net
: #gallery on irc://chat.freenode.net


== List of Translations ==
== 翻譯列表 ==
All available Gallery 2 translations, listed alphabetically along with the maintainers / translators. Some translations are 100% up to date and complete, others are only 2% complete or out of date. See: [http://gallery.menalto.com/localization/gallery2 Localization Report]. If you have the developer package of G2, you can run {{exampleurl|/lib/tools/reports/localization.php}} to see the status of all installed translations.
所有可用的Gallery2翻譯,都在此以字母表順序列出了,帶有維護(hù)者/作者名單。某些翻譯100%保持更新并且完成,某些則僅完成了2%或過(guò)期了。參見(jiàn) [http://gallery.menalto.com/localization/gallery2 本地化報(bào)告]。如果你有G2的開(kāi)發(fā)者整合包,就可以運(yùn)行{{exampleurl|/lib/tools/reports/localization.php}}來(lái)查看所有已安裝翻譯的狀態(tài)。


{| class="gallery" style="background-color: #eee; width: 800px"
{| class="gallery" style="background-color: #eee; width: 800px"
|-
|-
! align="left" width="200px" | Language
! align="left" width="200px" | 語(yǔ)言
! align="left" | Language Code
! align="left" | 語(yǔ)言代碼
! align="left" | Last Translator
! align="left" | 最后翻譯者
! align="left" | List of Translators
! align="left" | 翻譯者列表
|-
|-
|Afrikaans
|Afrikaans
第327行: 第326行:
|-
|-
|中國(guó)
|中國(guó)
Chinese [Simplified]
Chinese [簡(jiǎn)體]
|zh_CN
|zh_CN
|Wayne Zhang
|Wayne Zhang
第333行: 第332行:
|-
|-
|臺(tái)灣
|臺(tái)灣
Chinese [Traditional]
Chinese [繁體]
|zh_TW
|zh_TW
|Stephen Chu
|Stephen Chu

2008年10月25日 (六) 16:57的最新版本

Gallery2的本地化[ ]

綜述[ ]

Gallery是國(guó)際化的。不對(duì)特定語(yǔ)言文本消息的包含, 取而代之地,它使用特殊的方法追蹤文本 以進(jìn)行抽取并翻譯成其他語(yǔ)言。用戶則會(huì)看見(jiàn) 文本被翻譯成他們使用的語(yǔ)言版本。

為了能夠讓用戶看到Gallery文本的本地化版本, 就需要先將這些Gallery要顯示的文本消息進(jìn)行 翻譯。此過(guò)程就被稱為"本地化"。

這里我們嘗試說(shuō)明一下如何創(chuàng)建并維護(hù)G2中本地化 文件的內(nèi)容。這并不是特別困難的任務(wù), 但要求無(wú)論何時(shí)基礎(chǔ)內(nèi)容有改變,我們都要保證 各類文件的更新度。我們挺幸運(yùn)的,因?yàn)橛羞@樣的工具能 協(xié)助我們完成此類操作過(guò)程。

要求[ ]

為了能夠有效率地進(jìn)行,你需要在計(jì)算機(jī)上 安裝一些工具。我僅在FreeBSD box中做了測(cè)試,但我想如果用在Linux,Solaris或其他Unix類系統(tǒng) 上也不會(huì)太麻煩。在Windows上可能會(huì)有些難度, 但也是有可能實(shí)現(xiàn)的。 以下為必須安裝,并在你的路徑中:

gettext
http://www.gnu.org/software/gettext/
gmake (或make)
http://www.gnu.org/software/make/make.html
php二進(jìn)制
http://php.net
perl
http://perl.com

:如果你使用FreeBSD,并希望能取代make而使用gmake,因?yàn)镕reeBSD的默認(rèn)不與GNU兼容。

你還需要用當(dāng)前G2文件創(chuàng)建最新的翻譯。就目前的SVN或nightly快照版的運(yùn)行情況都不錯(cuò)。最新的G2開(kāi)發(fā)者版本也能運(yùn)行,但某些翻譯的字串可能有些過(guò)時(shí)了。

本地化的新建[ ]

瀏覽一下Gallery就能發(fā)現(xiàn)不少名為"po"的目錄。("po"是一gettext術(shù)語(yǔ),即"可移植對(duì)象(portable object)")。以下為找到它們的一個(gè)方法:

find . -type d -name po			<-- 輸入這個(gè)

./themes/matrix/po	          	<-- 會(huì)看到這個(gè)
./lib/tools/po
./modules/core/po
./modules/comment/po
./modules/netpbm/po

** 忽略"lib/tools/po"目錄。

這些目錄還有翻譯源文件。你要 使用合適的語(yǔ)言代碼來(lái)新建文件,接著在它們之中 添入經(jīng)過(guò)翻譯的文本。首先要做的就是從 下面的兩個(gè)表格中識(shí)別出正確的代碼:

語(yǔ)言代碼
http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC221
(or http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt)
國(guó)家代碼
http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC222
(or http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html)

在大多數(shù)情況下,你只需要語(yǔ)言代碼即可,如德語(yǔ)就是"de"。要為多個(gè)國(guó)家中提供特定國(guó)家語(yǔ)言的翻譯,你可以使用這樣的代碼格式,xx_XX,例如"pt_BR"表示葡萄牙語(yǔ)/巴西。如果你確定該用哪一個(gè),包括語(yǔ)言和國(guó)家。如果你發(fā)現(xiàn)已有你使用語(yǔ)言的翻譯的話,請(qǐng)接著看 本地化的維護(hù)。

一旦選好了代碼,就需要為你的代碼新建一個(gè).po 文件。假定你選擇是的"de"。那么對(duì)各po目錄, 你需要做的是:

make de.po

這將找到該本地化標(biāo)記的所有文本(tpl文件中的{g->text},php代碼中的translate()或i18n()),并創(chuàng)建一個(gè)即將進(jìn)行翻譯的po文件。

有關(guān)文本編輯器。

我比較喜歡用XEmacs,因此我會(huì) 在下面的例子中拿XEmacs做例子。如果你有其他編輯器 的使用指導(dǎo),請(qǐng)分享一下。XEmacs的主要模式被稱為"po-模式",如果你安裝了它,在編輯.po文件時(shí)就會(huì) 自動(dòng)轉(zhuǎn)入。我在這里不準(zhǔn)備這么做,但 你可以嘗試一下。

現(xiàn)在我們來(lái)編輯de.po。在其頂部應(yīng)有Gallery的證書。你需要對(duì)以下值做自定義:

Last-Translator
將你的名字及email以此格式輸入:"FirstName LastName <email@address>"
Language-Team
輸入語(yǔ)言及-翻譯郵件列表,如"German <gallery-translations@lists.sourceforge.net>"
Content-Type
將此設(shè)置給"Content-Type:text/plain; charset=UTF-8\n"
我們希望你使用UTF-8字符集。因?yàn)樗试S我們?cè)谕豁?yè)面上對(duì)多個(gè)語(yǔ)言進(jìn)行渲染,這對(duì)某一語(yǔ)言站點(diǎn)頁(yè)面上其他語(yǔ)言的用戶評(píng)論是有好處的。

這里有modules/core/po/de.po的完整的header樣例。注意編寫者是如何維護(hù)前任翻譯者名單的。

# 前任翻譯者(迄今所知,如有脫漏,請(qǐng)?jiān)诖颂砑樱?# - Jens Tkotz <jens@peino.de>
# - Ernesto Baschny <ernst@baschny.de>
...
#
msgid ""
msgstr ""
"Project-Id-Version: Gallery: Core 1.0.32\n"
"POT-Creation-Date: 2003-02-11 03:09-0800\n"
"PO-Revision-Date: 2006-03-05 02:25+0000\n"
"Last-Translator: Frederik Kunz <frederik.kunz@web.de>\n"
"Language-Team: German <gallery-devel@lists.sourceforge.net>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

如果你的語(yǔ)言中不包含復(fù)數(shù)詞用法,如漢語(yǔ)或土耳其語(yǔ),就得修改以下語(yǔ)句:

"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    -> Change to "Plural-Forms: nplurals=1; plural=0;\n".

這樣,你只需翻譯msgstr[0]并注釋掉或移除msgstr [1].

接著來(lái)看看Gallery證書下的語(yǔ)句行:

#, fuzzy
msgid ""
msgstr ""

模糊的關(guān)鍵詞告知你區(qū)塊的翻譯 不完整。但一旦更新了administration entry,就 可以移除"#, fuzzy"這一行以允許稍后翻譯的 編譯。

接下來(lái)你會(huì)看到一系列區(qū)塊:

#, c-format		(<-- 在某些語(yǔ)句行中僅能看到這個(gè))
msgid "a message in english, with %d or %s tags in it"
msgstr ""

你需要將英語(yǔ)消息的翻譯置入 msgstr區(qū)塊中,用引號(hào)括起來(lái),例如:

#, c-format
msgid "a message in english, with %d or %s tags in it"
msgstr "eine Anzeige auf englisch, mit %d oder %s etikettiert in ihr"

某些msgid值含有有助于進(jìn)行翻譯的提示信息:

#. HINT: Button label for Bold
msgid "B"
msgstr "F"

注意提示內(nèi)容不應(yīng)翻譯或包括在msgstr文本中。你可以使用翻譯追蹤器(Translations Tracker)為特殊字串請(qǐng)求額外的提示文本。指定模塊/外觀主題以及msgid。注意strings.raw文件列出了用到msgid的文件。

在編輯這些消息之前,你確實(shí)應(yīng)當(dāng)將編輯器設(shè)為UTF-8模式, 這樣編輯器才能使用正確的字符集。 如果你由于某種原因無(wú)法在UTF-8模式中進(jìn)行編輯, 請(qǐng)考慮使用GNU的"recode"程序,在提交翻譯內(nèi)容給我們之前, 將其轉(zhuǎn)為UTF-8(或者直接發(fā)給我們也許,我們會(huì)進(jìn)行重新編碼)。

如果你使用XEmacs的MULE(即多語(yǔ)言支持(MULtilanguagE)),你可以將一下內(nèi)容添加到 ~/.xemacs/init.el中去

; Enable Unicode support (via Mule-UCS)
;
(require 'un-define)
(set-coding-priority-list '(utf-8))
(set-coding-category-system 'utf-8 'utf-8)

當(dāng)你編輯UTF-8的文件時(shí),會(huì)有一些"u" 出現(xiàn)在屏幕底部狀態(tài)條左側(cè)。使用現(xiàn)有的 .po文件來(lái)看一看。

在進(jìn)行一些翻譯之后,來(lái)看看效果。運(yùn)行:

make install PO=de

它會(huì)將你的.po文件編譯到一個(gè).mo文件中,并將其安裝到合適的位置。在修改.po文件之后,對(duì)各目錄都要重復(fù)此步驟。如果你在創(chuàng)建locale目錄時(shí)發(fā)生錯(cuò)誤,請(qǐng)?jiān)谶\(yùn)行make之前建立目錄結(jié)構(gòu)(如:modules/mymodule/locale/de/LC_MESSAGES)。

最后,你需要編輯modules/core/classes/GalleryTranslator.class,并在函數(shù)getLanguageData中加入如下語(yǔ)句:

/* German */
$this->_supportedLanguages['de']['DE']['description'] = 'Deutsch';
$defaultCountry['de'] = 'DE';

批注應(yīng)為該語(yǔ)言的英語(yǔ)說(shuō)法;語(yǔ)言 '描述'則應(yīng)是該語(yǔ)言的本土說(shuō)法。

現(xiàn)在登入G2,在用戶偏好(你可能需要 通過(guò)站點(diǎn)管理對(duì)用戶進(jìn)行編輯)中,你應(yīng)能在下拉列表中看到 German。而如果你選擇了它,并以剛才那個(gè)用戶的身份登入的話, 就能看到消息被翻譯為該語(yǔ)言了。你還可以將語(yǔ)言選擇器區(qū)塊 添加到站點(diǎn)中,使用外觀主題設(shè)定就可以做到。

注: 如果語(yǔ)言修改沒(méi)有起效,請(qǐng)回顧一下語(yǔ)言設(shè)定的優(yōu)先級(jí)(會(huì)話語(yǔ)言(Session language) > 用戶偏好(user preferences) > 站點(diǎn)范圍的默認(rèn)語(yǔ)言(site wide default language))。如果有疑慮的話,可以使用語(yǔ)言區(qū)塊或在用戶偏好中反復(fù)嘗試。

本地化的提交[ ]

現(xiàn)在本地化就應(yīng)創(chuàng)建號(hào)了,你需要將其 打包并發(fā)送給我們,這樣我們就能將其添入存儲(chǔ)庫(kù)。 最好的打包方式如下:

cd gallery2
zip de.zip `find . -name de.po`

or:

cd gallery2
tar czf nl.tar.gz `find . -name nl.po`

你翻譯過(guò)的文件會(huì)被做成zipfile或tarball。當(dāng)然使用你自己的語(yǔ)言代碼取代上面的de或nl。接著瀏覽SourceForge 的Gallery項(xiàng)目頁(yè)面上的幫助部分)告知我們。

本地化的維護(hù)[ ]

cd po
make de.po	(using German as an example)

這會(huì)從你所在的模塊中提取出所有消息 并更新.po文件。瀏覽.po文件,找到所有具有 空msgstr或被標(biāo)記為"模糊(fuzzy)"的區(qū)塊并更新它們。在它們 被修復(fù)之后,移除fuzzy標(biāo)識(shí)。你看到的標(biāo)識(shí)會(huì)是如下的 樣子:

#, fuzzy
#~ msgid "User"
#~ msgstr "Gebruikersnaam"

"#, fuzzy"表示它是模糊的,但"#~"表明該 字串不存在于G2中(我們可能將其刪除或修改了 )。你可以刪除這些內(nèi)容.

你應(yīng)當(dāng)快速地做一次gettext提供的檢查,以驗(yàn)證.po文件:

msgfmt -v -c --stat de.po

當(dāng)一切都設(shè)置好后,運(yùn)行:

make install PO=de

翻譯文件被PHP緩存(這就是其快速的原因) 因此在重啟web服務(wù)器之前,可能無(wú)法看到所作的修改。這是 有點(diǎn)麻煩,但我還沒(méi)有想出好的解決辦法。

參見(jiàn)[[#本地化的新建]|本地化的新建]]部分的測(cè)試信息,并向我們提交新文件。

何處尋求幫助?[ ]

如果你需要幫助,有三個(gè)地方可以求助:

The Gallery translations forums
http://gallery.menalto.com/forum/74
The gallery-translations mailing list
http://codex.gallery2.org/index.php/Mailing_Lists
The Gallery IRC channel
#gallery on irc://chat.freenode.net

翻譯列表[ ]

所有可用的Gallery2翻譯,都在此以字母表順序列出了,帶有維護(hù)者/作者名單。某些翻譯100%保持更新并且完成,某些則僅完成了2%或過(guò)期了。參見(jiàn) 本地化報(bào)告。如果你有G2的開(kāi)發(fā)者整合包,就可以運(yùn)行http://www.example.com/gallery/lib/tools/reports/localization.php來(lái)查看所有已安裝翻譯的狀態(tài)。