LOCALE::PO4A::SGML.3PM
Section: User Contributed Perl Documentation (1)Updated: 2025-05-04
Index Return to Main Contents
名稱
Locale::Po4a::Sgml - 將 SGML 文件從/轉換為 PO 檔案描述
Po4a (PO For Anything) 專案的目標是在文件等不需要翻譯的領域使用 gettext 工具簡化翻譯(更有趣的是,簡化翻譯的維護)。Locale::Po4a::Sgml 是一個幫助將 SGML 格式的文件翻譯成其他 [人類] 語言的模組。
本模組使用 onsgmls(1) 解析 SGML 檔案。確保它已安裝。還要確保 SGML 檔案的 DTD 已安裝在系統中。
此模組接受的選項
- debug
- Space-separated list of keywords indicating which category of extra debug messages should be shown. Possible values are: "entities", "generic", "onsgml", "refs" and "tag".
- verbose
- 給出更多關於正在發生的事情的資訊。
- translate
- Space-separated list of extra tags (beside the DTD provided ones) whose content should form an extra msgid, i.e that should be translated.
- section
- Space-separated list of extra tags (beside the DTD provided ones) containing other tags, some of them being of category translate.
- indent
- Space-separated list of tags which increase the indentation level. This will affect the indentation in the resulting document.
- verbatim
- 這些標籤內的佈局不應更改。段落不會換行,也不會新增額外的縮排空間或新行用於修飾。
- empty
- 標籤不需要關閉。
- ignore
- Tags ignored and considered as plain char data by po4a. That is to say that they can be part of an msgid. For example, <b> is a good candidate for this category since putting it in the translate section would create a msgids with only its content, (and it's usually not a whole sentence), which is bad.
- attributes
- A space-separated list of attributes that need to be translated. You can specify the attributes by their name (for example, "lang"), but you can also prefix it with a tag hierarchy, to specify that this attribute will only be translated when it is into the specified tag. For example: "<bbb><aaa>lang" specifies that the lang attribute will only be translated if it is in an "<aaa>" tag, which is in a "<bbb>" tag. The tag names are actually regular expressions so you can also write things like "<aaa|bbb>lang" to only translate "lang" attributes that are in an "<aaa>" or a "<bbb>" tag.
- qualify
- A space-separated list of attributes for which the translation must be qualified by the attribute name, i.e. the text extracted for the translation will include both the attributes name and it's value. e.g. for a tag like "<aaa lang_en="foo">" translators will be presented with the string "lang_en="foo"". Note that this also automatically adds the given attribute into the attributes list too.
- force
- Proceed even if the DTD is unknown or if onsgmls finds errors in the input file.
- include-all
- By default, msgids containing only one entity (like "&version;") are skipped for the translators' comfort. Activating this option prevents this optimisation. It can be useful if the document contains a construction like "<title>Á</title>", even if I doubt such things to ever happen...
- ignore-inclusion
- Space-separated list of entities that won't be inlined. Use this option with caution: it may cause onsgmls (used internally) to add tags and render the output document invalid.
此模組的狀態
The result is perfect. I.e., the generated documents are exactly the same as the originals. But there are still some problems:- •
-
The error output of onsgmls is redirected to /dev/null by default, which is clearly bad. I don't know how to avoid that.
The problem is that I have to "protect" the conditional inclusions (i.e. the "<! [ %foo [" and "]]>" stuff) from onsgmls. Otherwise onsgmls eats them, and I don't know how to restore them in the final document. To prevent that, I rewrite them to "{PO4A-beg-foo}" and "{PO4A-end}".
這樣做的問題是,"{PO4A-end}" 和 I 新增的內容在文件中無效(不在 <p> 標記中)。
If you want to view the onsgmls output, just add the following to your command line (or po4a configuration line):
-o debug=onsgmls
- •
-
它只適用於 DebianDoc 和 DocBook DTD。新增對新 DTD 的支援應該非常容易。該機制對於每個 DTD 都是相同的,您只需給出現有標記及其一些特徵的列表。
我同意,這需要更多的文件,但它仍然被認為是測試版,我討厭記錄可能/將會改變的東西。
- •
-
警告,對 DTD 的支援只是試驗性的。我沒有閱讀任何參考手冊來查詢每個標籤的定義。我確實在模組中添加了標籤定義,直到它適用於我在網上找到的一些文件。如果你的文檔使用的標籤比我的多,它就不會起作用。但正如我上面所說的,修復這個問題應該是相當容易的。
我只針對 SAG (系統管理員指南)測試了 DocBook,但是這個文件相當大,應該使用大多數 DocBook 特性。
對於 DebianDoc,我測試了 DDP 的一些手冊,但還沒有全部測試。
- •
-
在包含檔案的情況下,PO 檔案中訊息的字串引用(即類似 "#: en/titletoc.sgml:9460" 的行)將是錯誤的。
This is because I preprocess the file to protect the conditional inclusion (i.e. the "<! [ %foo [" and "]]>" stuff) and some entities (like "&version;") from onsgmls because I want them verbatim to the generated document. For that, I make a temp copy of the input file and do all the changes I want to this before passing it to onsgmls for parsing.
為了使其正常工作,我將請求包含檔案的實體替換為給定檔案的內容 (這樣我也可以保護子檔案中需要的內容)。但是到目前為止,沒有采取任何措施來糾正後面的引用 (即文件名和行號)。我不確定最好的辦法是什麼。
作者
此模組是 sgmlspl (用於 ONSGMLS 解析器的 SGML 後處理器) 的改編版本,它是:
版權所有 © 1995 David Megginson <dmeggins@aix1.uottawa.ca>
對 po4a 的改編是透過以下方式完成的:
Denis Barbier <barbier@linuxfr.org> Martin Quinson (mquinson#debian.org)
版權和許可
版權所有 © 1995 David Megginson <dmeggins@aix1.uottawa.ca>。 版權所有 © 2002-2005 SPI, Inc.
This program is free software; you may redistribute it and/or modify it under the terms of GPL v2.0 or later (see the COPYING file).
Index
This document was created by using the manual pages.
Time: 17:05:10 GMT, May 04, 2025