Next: Useful Hints for Editing PO Files, Previous: Special GNUN messages, Up: Working with PO Files [Contents][Index]
Most of the PO editors do not wrap long lines that inevitably appear in
msgstr
s. If that happens, long lines make reading subsequent
diffs harder, and are generally annoying for most people. If this issue
bothers you, you can “normalize” the already finished PO translation
by executing on the command line msgcat -o file.po
file.po
, before installing it in the repository. Either way, the
build system will treat it as a valid PO file.
For those lucky Emacs users, here is a code snippet that you can put in your .emacs; doing M-x po-wrap while in PO mode will wrap all long lines:
(defun po-wrap () "Filter current po-mode buffer through `msgcat' tool to wrap all lines." (interactive) (if (eq major-mode 'po-mode) (let ((tmp-file (make-temp-file "po-wrap.")) (tmp-buf (generate-new-buffer "*temp*"))) (unwind-protect (progn (write-region (point-min) (point-max) tmp-file nil 1) (if (zerop (call-process "msgcat" nil tmp-buf t (shell-quote-argument tmp-file))) (let ((saved (point)) (inhibit-read-only t)) (delete-region (point-min) (point-max)) (insert-buffer tmp-buf) (goto-char (min saved (point-max)))) (with-current-buffer tmp-buf (error (buffer-string))))) (kill-buffer tmp-buf) (delete-file tmp-file)))))
It is highly desirable that you check if the PO file you finished
translating (or editing) is valid, before committing it. This is done
by running msgfmt -cv -o /dev/null file
or by simply
pressing V in PO mode. The build system automatically verifies
each PO file when invoked with VALIDATE=yes
, but you won’t get a
warm and fuzzy feeling if a stupid typo you made halts the whole update
of all translations. Such things happen to everyone, so it is a good
practice to check before you actually commit.
Next: Useful Hints for Editing PO Files, Previous: Special GNUN messages, Up: Working with PO Files [Contents][Index]