TÊN

po-debconf — giới thiệu


MÔ TẢ

The goal of debconf was to make package configuration user-friendly. In order to achieve this, it is important to ensure that users will get the question in their own language. Translators need a framework to easily work on translations without having to track package development; po-debconf was designed to be able to work with standard gettext tools when translating debconf templates files.


THÊM HỔ TRỢ I18N VÀO TẬP TIN MẪU DEBCONF

Muốn thêm hỗ trợ debconf vào gói thì bạn đã ghi một tập tin mẫu chứa văn bản tiếng Anh (ngôn ngữ gốc). Để thêm khả năng hỗ trợ tiến trình quốc tế hoá (i18n) vào gói, bạn cần phải:

• Tạo debian/po/POTFILES.in

Tập tin này chứa danh sách các mẫu chủ. Bình thường nó chứa chỉ một dòng riêng lẻ:

  [type: gettext/rfc822deb] templates

Đường dẫn tương đối với thư mục cha.

- Prepend an underscore before translatable fields in each template

Bình thường có thể dịch được các trường kiểu Description, Choices và đôi khi Default.

• Chạy debconf-updatepo

Tiến trình này sẽ tạo tập tin debian/po/templates.pot mà người dịch sẽ dịch sang ngôn ngữ khác.

• Thêm vào debian/control một quan hệ phụ thuộc xây dựng vào po-debconf.


CẬP NHẬT MẪU

In order to help translators, PO files in your package should always be up-to-date, otherwise they may waste their time translating unused strings. For that, simply call the following command without arguments:

  $ debconf-updatepo

Để duy trì các tập tin PO hiện thời, bạn nên chạy lệnh này mỗi lần thay đổi chuỗi tiếng Anh trong mẫu. Cũng nên chạy nó khi bạn nhận bản dịch mới hay bản dịch đã cập nhật, vì người dịch có thể đã dịch tập tin PO cũ.

Nếu bạn thay tên, thêm hay gỡ bỏ bất kỳ tập tin mẫu, cũng nhớ để chỉnh sửa tập tin debian/po/POTFILES.in một cách tương ứng. Không thì một số chuỗi tiếng Anh bị thiếu trong tập tin PO; các chuỗi tiếng Anh này sẽ được hiển thị cho người dùng xem, thậm chí nếu các tập tin PO đã được dịch hoàn toàn.

The debconf-updatepo program is idempotent, it modifies PO files only if their content has been updated. Thus the best way to provide up-to-date PO files in your source package is to call this command from the clean target of the debian/rules file.

Ghi chú rằng bạn cần phải chạy debconf-updatepo thậm chí nếu bạn sử dụng dh_installdebconf. Hàm thứ hai này gọi po2debconf mà từng gọi debconf-updatepo nếu phát hiện tập tin bị lỗi thời, nhưng không còn là trường hợp lại vì hai lý do :

  1. po2debconf nhờ nhãn giờ để phát hiện tập tin bị lỗi thời, và có thể không chạy đúng khi dùng pbuilder hoặc nếu bản dịch cũ đã được lưu vào đĩa sau khi mẫu bị sửa đổi.

  2. dh_installdebconf được gọi đã lâu sau khi tạo ra tập tin .diff.gz.


TRỘN BẢN DỊCH VỚI BẢN GỐC

Bạn cần phải kiểm tra các bản dịch được hợp nhất trong gói đã xây dựng khi nó được biên dịch. Bạn có thể tự kiểm tra, hoặc tự động kiểm tra bằng cách sử dụng văn lệnh dh_installdebconf (hãy đảm bảo có một quan hệ phụ thuộc xây dựng đặt phiên bản với debhelper (>= 4.1.16)).

Để tự kiểm tra, bạn cần phải trộn các mẫu với các bản dịch vào lúc biên dịch (và đặt quan hệ phụ thuộc xây dựng với po-debconf) như thế:

  $ po2debconf debian/templates > debian/tmp/DEBIAN/templates

BE CAREFUL: hai tập tin tên templates không phải trùng nhau. Tập tin thứ nhất chứa chỉ văn bản gốc (thường là tiếng Anh), và đánh dấu một số trường cần dịch, còn tập tin thứ hai chứa tất cả các ngôn ngữ. Vì vậy bạn KHÔNG thể giữ chỉ những mẫu đã trộn: có giữ thì bạn không thể xử lý mỗi bản dịch được đệ trình.


MẪU CHỦ MỚI

Định dạng nguồn tập tin mẫu mới là gần trùng với một của những tập tin mẫu đã phát hành, nhưng mỗi trường có thể dịch được có dấu gạch dưới nằm trước. Thí dụ :

  Template: debconf/frontend
  Type: select
  _Choices: Dialog, Readline, Gnome, Editor, Noninteractive
  Default: Dialog
  _Description: Interface to use for configuring packages:
   Packages that use debconf for configuration share a common look and
   feel.  You can select the type of user interface they use.
   .
   The dialog frontend is a full-screen, character based interface,
   while the readline frontend uses a more traditional plain text
   interface, and the gnome frontend is a modern X interface.  The
   editor frontend lets you configure things using your favorite text
   editor. The noninteractive frontend never asks you any questions.

XẺ DANH SÁCH TÙY CHỌN

Since po-debconf 0.6.0, localized fields may contain two leading underscores. In this case, the field value is supposed to be a comma separated list of values, which are put in separate msgids. Thus if the previous example did contain

  __Choices: Dialog, Readline, Gnome, Editor, Noninteractive

thì tạo 5 chuỗi msgid khác nhau. Ghi chú rằng dấu cách nằm sau dấu phẩy không có nghĩa.

When a choices list never changes, _Choices may be considered fine. However, splitting such lists may help avoiding frequent mistakes in translations such as omitting a choice or using non-standard commas. For such reasons, the use of __Choices will ease translator's life and is strongly recommended.

Unfortunately if you decide to switch from _Choices to __Choices, all translations become fuzzy. Here is an explanation to make this change without translation loss (it requires po-debconf >= 1.0). Suppose that we want to switch the previous example to __Choices. You copy the templates file into a temporary file.

  $ cp debian/templates debian/foo

Sửa debian/foo, giữ chỉ những trường Template, Type_Choices mà nằm trong thí dụ này.

  Template: debconf/frontend
  Type: select
  _Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive

Chạy debconf-gettextize với hai cờ --merge--choices để xây dựng các tập tin PO như thể là __Choices đã được ghi, và trộn các tập tin PO này với các tập tin đã tồn tại:

  $ debconf-gettextize --merge --choices debian/foo

Cuối cùng bạn cần phải gỡ bỏ foo và tự chỉnh sửa debian/templates để thay thế _Choices bằng __Choices trước khi chạy debconf-updatepo.

PUTTING IN COMMENTS FOR TRANSLATORS

Dpkg maintainers decided that by convention lines beginning with a number sign (#) are comments in debian/control files, and po-debconf follows this rule. Since po-debconf 0.8.0, such comments are written into PO files, and can then contain valuable information for translators. Incidentally all previous po-debconf versions ignore lines which do not contain a colon, thus if your comments does not contain any colons, there is no need to add a versioned build dependency against po-debconf. Here is an example:

  Template: debconf/button-yes
  Type: text
  # Translators, this text will appear on a button, so KEEP IT SHORT
  _Description: Yes

Chú thích đặc biệt đã được giới thiệu trong po-debconf 1.0 để quản lý chuỗi chứa vài mục khác nhau (như trong trường Choices) hay vài đoạn văn khác nhau (như Description). Hai chỉ thị này cho nhà phát triển điều khiển hữu ích hơn thông tin được hiển thị cho người dịch. Chú thích này theo dạng #flag:directive; các chỉ thị được diễn tả bên dưới.

translate:spec, translate!:spec

Đánh dấu chỉ một số mục là « có thể dịch được »; spec là danh sách con số định giới bằng dấu phẩy, nó xác định những chuỗi nào sẽ được in ra tập tin PO. Cũng có thể xác định phạm vi bằng dấu trừ (v.d. 2-6), và dấu sao (*) có nghĩa « mọi chuỗi ». Chẳng hạn, đối với

  Template: partman-basicfilesystems/fat_mountpoint
  Type: select
  #flag:translate:3,4
  __Choices: /dos, /windows, Enter manually, Do not mount it
  _Description: Mount point for this partition:

Hai mục Enter manuallyDo not mount it sẽ xuất hiện trong tập tin PO, nhưngkhông phải hai mục /dos/windows. Có dấu chấm than nằm sau từ khoá translate thì spec xác định những chuỗi nào sẽ bị hủy ra tập tin PO: các chuỗi khác được in ra. Thí dụ trước tương tự với

  Template: partman-basicfilesystems/fat_mountpoint
  Type: select
  #flag:translate!:1,2
  __Choices: /dos, /windows, Enter manually, Do not mount it
  _Description: Mount point for this partition:

Có thể áp dụng cùng từ khoá cho trường Description để đảm bảo một số chuỗi riêng sẽ không được dịch.

  Template: partman-crypto/options_missing
  Type: error
  #flag:translate!:3
  _Description: Required encryption options missing
   The encryption options for ${DEVICE} are incomplete. Please
   return to the partition menu and select all required options.
   .
   ${ITEMS}

Nhưng mà trường hợp này nguy hiểm, vì ngữ cảnh có thể bị hủy ra tập tin PO: hãy ghi chú để cho người dịch thông tin cần thiết.

comment:spec, comment!:spec

Ghi chú đúng bên dưới chỉ thị này áp dụng cho những chuỗi được ghi rõ bởi spec, mà được xác định bên trên. Mặc định là ghi chú được ghi vào đằng trước một trường có thể dịch được thì được in ra cùng với tất cả các chuỗi thuộc về trường đó. (Ghi chú : dùng po-debconf < 1.0, ghi chú được ghi chỉ với chuỗi thứ nhất.)

  Template: arcboot-installer/prom-variables
  Type: note
  # Translators, the 4th string of this description has been dropped
  # from PO files.  It contains shell commands and should not be
  # translated.
  #flag:comment:3
  # "Stop for Maintenance" should be left in English
  #flag:translate!:4
  _Description: Setting PROM variables for Arcboot
   If this is the first Linux installation on this machine, or if the
   hard drives have been repartitioned, some variables need to be set
   in the PROM before the system is able to boot normally.
   .
   At the end of this installation stage, the system will reboot.
   After this, enter the command monitor from the "Stop for
   Maintenance" option, and enter the following commands:
   .
      setenv OSLoader arcboot
      setenv OSLoadFilename Linux
   .
   You will only need to do this once.  Afterwards, enter the "boot"
   command or reboot the system to proceed to the next stage of the
   installation.

Thí dụ bên trên có một ghi chú mà không dùng chỉ thị #flag:comment, vào đó một #flag:comment:* ngầm được thêm. Ghi chú này xuất hiện với mọi chuỗi, nhưng lời về Stop for Maintenance được in ra chỉ đằng trước chuỗi thích hợp.

partial

Từ khoá này báo po2debconf nên giữ lại các chuỗi đã dịch, thậm chí nếu chưa dịch mọi chuỗi. Hãy sử dụng cẩn thận: từ khoá này đã được giới thiệu nhằm mục đích chính xác.

THÔNG BÁO NGƯỜI DỊCH TRƯỚC KHI TẢI LÊN

Dù người dịch có thể thấy bản dịch cũ trên các trang Web trạng thái (xem dưới), và gửi đắp vá để bao gồm trong bản tải lên về sau, người dịch (giống như nhà phát triển) có ít thời gian rảnh. Để tiết kiệm thời gian cho cả hai nhà phát triển và người dịch, và cải tiến tiến trình liên lạc giữa cả hai, Dự án Debian cung cấp một công cụ chuyên dụng, podebconf-report-po. Dùng công cụ này, bạn có thể yêu cầu người dịch trước cập nhật bản dịch (v.d. 2 tuần đằng trước ngày tải lên), cuối cùng nhận nhiều bản dịch được cập nhật hơn. Rất khuyên nhà phát triển sử dụng công cụ này.


DEBUGGING

You will find that debconf-loadtemplate will not accept a templates file with i18n markups. However, it will accept a merged file, so if you have been debugging your debconf setup like this

  rm /tmp/{config,templates}.dat{,-old}
  debconf-loadtemplate debian/templates
  DEBIAN_PRIORITY=low debconf -freadline debian/config configure 28.0

you will now need something like this instead:

  po2debconf debian/templates > debian/tmp/DEBIAN/templates
  rm /tmp/{config,templates}.dat{,-old}
  debconf-loadtemplate debian/tmp/DEBIAN/templates
  DEBIAN_PRIORITY=low debconf -freadline debian/config configure 28.0


CẨN THẬN


TRANG WEB TRẠNG THÁI

Thống kê về bản dịch po-debconf sẵn sàng ở http://www.debian.org/intl/l10n/po-debconf/ (hoặc từ máy nhân bản); tất cả được tự động cập nhật khi gói mới được tải lên. Chỉ gói có sẵn tập tin debian/po/templates.potdebian/po/POTFILES.in được xử lý, vì vậy bạn nên kiểm tra gói mã nguồn chứa các tập tin này.

Người dịch có thể lấy tập tin PO và POT từ trang trạng thái, nhưng cũng nên liên lạc với người dịch trước (địa chỉ thư điện tử nằm trong phần đầu của tập tin PO) và/hay nhóm dịch trong hộp thư chung debian-l10n-<language>@lists.debian.org (nếu có : một số nhóm dịch dùng hộp thư chung bên ngoài) để kiểm tra không có người dịch khác đảm nhận cùng bản dịch, và đọc các báo cáo lỗi hiện thời về gói đó để kiểm tra bản dịch đã được đệ trình chưa.

Sau khi dịch tập tin thì người dịch nên đệ trình bản dịch cho nhà duy trì bằng cách gửi một báo cáo lỗi có mức quan trọng wishlist và thẻ patch.


XEM CŨNG

debconf-gettextize(1), debconf-updatepo(1), dh_installdebconf(1), podebconf-report-po(1), po2debconf(1), debconf-devel(7).


TÁC GIẢ

  Martin Quinson <Martin.Quinson@ens-lyon.fr>
  Denis Barbier <barbier@linuxfr.org>