Re: PO-based Documentation Translation

Tim Foster <Tim.Foster@Sun.COM> writes:

> Yeah - that would work, - you're getting the differences displayed, but
> not taking advantage of the matches you'd get across other projects if
> you could segment at the sentence level.

Yes, you are right.  OTOH, it would be that difficult to enhance
po-mode (Emacs) doing a lookup for arbitrary fragments of an entry:

    1. Mark the fragment you are interested in

    2. Build a temporary pot file with just this fragment and call
       'msgmerge -C compendium.po /dev/null tmp.pot' on it.

I'll give it a try.  Here is the proof of concept (don't forget to set
po-compendium-file first); mark the substring of an msgid you are
interested in and then call M-x po-fragment-lookup-compendium RET - in
case of success the usual edit buffer sould appear:

(defvar po-compendium-file nil
  "*Set to FILENAME of the compendium file.")

(defun po-fragment-lookup-compendium (start end)
  "Lookup `po-compendium-file' for a translation."
  (interactive "r")
  (let ((dev-null
	 (cond ((boundp 'null-device) null-device) ; since Emacs 20.3
	       ((memq system-type '(windows-nt windows-95)) "NUL")
	       (t "/dev/null")))
	(oldbuf (current-buffer)))
    (if (null po-compendium-file)
	(error "No compendium file set; check `po-compendium-file'")

      ;; stick msgid to lookup in " *po-lookup" and lookup the
      ;; compendium to find a translation proposal; add it to the msgid
      ;; and save it in the kill ring
	(set-buffer (get-buffer-create " *po-lookup"))
	(setq buffer-read-only nil)
	(insert "msgid \"")
	(insert-buffer-substring oldbuf start end)
	(insert "\"\nmsgstr \"\"\n")
	(call-process-region (point-min) (point-max) "msgmerge" t t t
			     "-C" (expand-file-name po-compendium-file)
			     null-device "-q" "-o" "-" "-")
	;; FIXME: if nothing found exit gracefully

      ;; yank the found translation proposal in a subedit buffer
      (if (looking-at "[#<]")
	  ;; the subedit buffer is empty; just yank
	  (progn (yank)
		 (if (looking-at "#") (insert "\n")))
	(insert "\n#-#-#-#-#  old translation variant(s)  #-#-#-#-#\n")))))

> Of course, context is important, but in the absence of anything else, we
> can suggest the match - a reviewer doesn't have to use an exact match we
> suggest, but usually it's acceptable.
> In terms of saving time and money, sentence segmentation is fantastic
> and works for us.

Okay. As long as the sequence of the sentences is available translators
will be happy.

                                                         |      ,__o
                                                         |    _-\_<,                            |   (*)/'(*)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]