Next: Validating 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)))))