「MozLCDB Manual」修訂間的差異

出自 MozTW Wiki

The author and "Why a new tool?" 關於作者以及「為何要用新工具」?
行 2: 行 2:
該文件原文位於 [http://moztw.org/tools/mozlcdb/ http://moztw.org/tools/mozlcdb/]<br>
該文件原文位於 [http://moztw.org/tools/mozlcdb/ http://moztw.org/tools/mozlcdb/]<br>
另外,請大家翻譯時,使用全形的標點符號(如 "," 和 "。" 而非 "," 或 ".")<br>
另外,請大家翻譯時,使用全形的標點符號(如 "," 和 "。" 而非 "," 或 ".")<br>
==MozLCDB: What is it? 什麼是 MozLCDB 呢?==
==MozLCDB: What is it? 什麼是 MozLCDB 呢?==

於 2005年2月7日 (一) 12:17 的修訂

由於有人在討論區上提議要把 piaip 的 MozLCDB 文件翻成中文,所以把大家翻的放到這邊。
該文件原文位於 http://moztw.org/tools/mozlcdb/
另外,請大家翻譯時,使用全形的標點符號(如 "," 和 "。" 而非 "," 或 ".")

MozLCDB: What is it? 什麼是 MozLCDB 呢?

MozLCDB is a tool made for localization of various Mozilla (Gecko) based products. It is designed to resolve issues introduced since Mozilla Firefox 1.0 branch, and a replacement for MozillaTranslator.

MozLCDB 是為了眾多基於 Mozilla (Gecko) 產品的本地化而設計的工具。它是為了解決由 Mozilla Firefox 1.0 產生的問題,也是 MozillaTranslator 的替代品。
by Milo

The author and "Why a new tool?" 關於作者以及「為何要用新工具」?

This is Hung-Te Lin, maintainer of Traditional Chinese Mozilla Localization and the famous "mozip" (a tool to make Win32 localized builds).

我是林弘德。Mozilla 正體中文本地化以及知名的 mozip (一個編譯 Win32 本地化版本的工具)的維護者。

I have been using MozillaTranslator for years (whether the official builds or my own tweaked versions) since Mozilla M14 (Milestone 14, not 1.4. The M series are older than Mozilla 0.6). During these years MT works O.K although more and more extra works have to be done because Mozilla locale structure changes all the time.

我從 Mozilla M14 (Milestone 14,不是 Mozilla 1.,M 系列比 Mozilla 0.6 還要早) 開始使用 MozillaTranslator(MT) 已經許多年了(不論是正式版本或是我修改過的)。這些年來 MT 都可正常運作,雖然由於 Mozilla 的 locale 架構經常改變,需要下更多額外的功夫。

Since the landing of Mozilla Firefox 1.0PR, localizers of Mozilla* suffered from the huge changes in Mozilla locale structure and new CVS requirements. Unfortunately, MozillaTranslator does not work anymore. Although MT has released new versions to solve issues, after trying MT5.04 I think it's time to develop a new tool which is more robust or I have to manually do many extra work for all versions. With my experience in localization, I proposed what I need and made a new tool, named MozLCDB. This name is a little weird because the better name 'MLDB' is already taken by others. Hmmm. Maybe MLD?

I'm not an perl guru so this script is not perfect nor elegant now, but it helped me to generate a working Firefox 1.0PR locale without too much effort (in comparision to fight with MozillaTranslator).

自從 Mozilla Firefox 1.0PR 推出後,Mozilla* 的許多本地化作者因為 Mozilla 的 locale 架構和新的 CVS 需求巨大的變化而遭遇許多麻煩。不幸地,MozillaTranslator 沒有用了。雖然 MT 發布新版本解決了很多問題,在用過 MT5.04 之後我認為是發展更加強大的新工具的時候了,否則我得爲新版本手動處理很多東西。我在本方化方面的經驗中,我檢討了我的訴求並且做了一套新工具,名為 MozLCDB。這個名稱是有點古怪,因為更好的名稱 「MLDB」已經有其他人使用了。嗯...可能可以叫 MLD?

我並不是 perl 高手因此這個 script 並不完美也不好看,但它讓我不須花太大功夫就能建立 Firefox 1.0PR 的 locale(與其與 MozillaTranslator 奮鬥)。 by tszkin, modded by Kourge

Features of MozLCDB MozLCDB 的功能

MozLCDB is focused to Mozilla Localization. In comparsion to MozillaTranslator, you'll notice that:

  • MozLCDB is just a perl script with command line only, no GUI.

You can (and you have to) edit all stuff with your favorite editor.

  • Targeted for Multiple Product maintaince.

That is, you can really localize Mozilla, Firefox, Thunderbird, Netscape, and keep only one instance for same chrome node.

  • Works for both CVS and downloaded ZIP language packs
  • The stored database is more human readable/editable
  • Single locale per database file. Does not support multiple locale (MT does).

You have to use multiple database files if you need multiple locale.

  • Easily modified if you understand Perl.

MozLCDB 主要用於 Mozilla 本地化。相比 MozillaTranslator 來說,你會注意到:

  • MozLCDB 是只有命令列模式(Command Line)的 Perl Script,沒有 GUI。


  • 可以針對多個產品維護。

也就是說,你可以本地化 Mozilla, Firefox, Thunderbird, Netscape 而只需使用一個相同 Chrome 節點的實體。

  • 能與一起 CVS 協同工作及下載 ZIP 語言套件
  • 儲存的資料庫格式更可讓人類讀寫。
  • 每個資料庫檔只支援一個 Locale。不支援多 Locale (MT 可以)。

假如你需要製作多個 Locale,你要使用多個資料庫檔案。

  • 假如你了解 Perl 語言,這支程式可是相當容易修改。

by a guest on the forums

Requirements 系統需求


  • Perl 5.8 或以上版本
  • 你所偏好的編輯器 (要有能力開啟及儲存 UTF-8,比如我選擇的是 VIM)
  • (選用) 如果你要使用 ZIP 或是 JAR 語言套件或是你想匯入 MozillaTralsator 的詞庫,需要任一種類的 ZIP 壓縮程式
  • (選用) 如果你想要匯入 MozillaTralsator 的詞庫,你需要 Python 2.0+
  • (選用) Perl 的相關知識,這樣你遇到問題才可以自行解決或是修改它

by Jose Sun

Download 下載


  • 最新版本: 2004 年 8 月 2 日,星期六 11:00:43 CST (hack on your own!)
  • 釋出版本:
    • 版本 0.2 (穩定版本,FF1.0/TB0.8 測試通過)
    • 版本 0.1 (有點小錯誤)

by Jose Sun

Background Knowledge 背景知識

這一節會解釋 MozLCDB 的基本想法。雖然你使用它的時候不需要任何底下說的知識,但是可以幫助你更了解它。是的,如果你趕時間的話可以直接到 "用法:" 這一節。但是無論如何我都強烈建議你在開始之前先把這些知識弄清楚。

Workflow 工作流程

我試著在這裡解釋 MozLCDB 的工作流程。不用擔心那些標記起來的術語,接下來的小節都會一一解釋。

基本上,MozLCDB 以這種方法運作:MozLCDB 會從 '已備妥目錄' (可以從 CVS 或 ZIP 語言套件取得)試著 '匯入' 資料,然後儲存並合併到 '(詞彙) 資料庫'。If any new locale string or updated ones are found, these entries will be written to an 'input (editing) table'. You can then edit the input table to do localization. After everything is done, you have to 'update' the '(glossary) database' with your 'input (editing) table'. Then you can 'export' the locales to another 'prepared directory'. Finally, the 'prepared directory' will contain all the localized stuff. File Format and Default Filenames

      MozLCDB tries to record everything in a text file named 'mozlcdb.txt'. It is saved in perl Dump format, however it is still readble ( if you know a little perl) and also called as the 'glossary' (due to MT) or 'database'. And there's another format of input that MozLCDB can read: the input (editing) table. It is more human readble and looks like DOS/WIN INI or GNU PO format. The default file name of this kind file is 'current.txt'. When importing from and exporting to Mozilla locale directories, currently MozLCDB recognizes only DTD and ".properties" files. 

Import, Export, and Update

   import means to read locales from Mozilla files into the database.
   export means to write locales from database into real Mozilla files.
   update means to read locales from an input (editing table) into the database.

Directory Structure

      Mozilla locale is stored in a hierarchical directory structure, also refered as chrome node. So you will see a very long path like "locale/en-US/global/global.dtd" in the directory you pulled from CVS or extracted from a language pack. MozLCDB mostly runs with the level just after where 'en-US' sits, so whether you're working with CVS or language pack, you must move directories (or move mozlcdb program and files) and assign correct ROOT path to fit thie rule. Then it can be called as a 'prepared directory'. (P.S: Actually, you can run in any level of directories. But you may get problems if you work in that way.)


      What's the ROOT? It's a PATH to help MozLCDB find corresponding locale path. For example, if my current directory is D:\Mozilla\LC (Win) or /home/moz/lc (UNIX) and my locale is in full path of D:\Mozilla\LC\locale\en-US\global\... or /home/moz/lc/locale/en-US/global/..., then you have to use ROOT as locale/en-US. 

The procedure of 'Import'and Multiple Product

      What really happened when you 'import'? MozLCDB will scan and walk through all files inside the 'prepared directory' assigned by ROOT. Currently, only *.dtd and *.properties will be processed. All other files will be ignored.
      When one DTD or properties file was found, MozLCDB first reads its content for the 'key's and original locales. If a key was not found (never seen), it will be inserted into database as a 'new' entry. If a key was found, MozLCDB will determine what to do depending on the original (en-US) locale message. If it is exactly same as some version recorded in database, it is considered a 'same' entry with no new entries introduced. If no entries with same original could be found, MozLCDB will append one entry with timestamp into database. This is the magic to make multiple product possible. We keep all versions of original messages. 

The procedure of 'Export'

      What really happened when you 'export'? MozLCDB will scan and walk through all files inside the 'prepared directory' assigned by ROOT. Currently, only *.dtd and *.properties will be processed. All other files will be ignored.
      When one DTD or properties file was found, MozLCDB first reads its content for the 'key's and original locales, then try to lookup database to decide what localized string to put in. If you export with '-x', MozLCDB assume you are working with a clean original copy exactly just what you have imported, so it will check for existence of keys and original locale message. However, you may want to export to a working (trial) copy. In that usage, -x will warn and stop because original message is filled with your localized strings. In this case you may use '-X' which will not check for keys.