Emacs/po-mode: po-lookup-compendium (Re: Insanely long messages ingnome-lokkit)



Karl Eichwalder <ke@suse.de> writes:

> Martin Norbäck <d95mback@dtek.chalmers.se> writes:
>
>> 2001-10-02 09:30:45+0200, Stanislav Visnovsky <visnovsky@nenya.ms.mff.cuni.cz> ->
>> > Comment on fuzzy status: In KBabel there is a DIFF mode to find out
>> > changes made in a message. It compares the current message and one in the
>> > translation memory. Maybe GTranslator should incorporate such a
>> > function?
>> 
>> It would certainly help those who are using KBabel or GTranslator. But
>> it won't help those who are editing po-files directly.
>> 
>> And this will also only help if you have the old translation in the
>> translation memory.
>
> I'll try to provide a similar feature for Emacs/po-mode.el (using
> ediff).  Or is such a patch already available?

Here's a way to query a compendium file; set `po-lookup-compendium' to
the file name that holds your translations:

    (setq po-compendium-file "~/Projects/trans/compendium-LL.po")

I'm interested to know whether it works for encodings besides Latin-1.
When the PO file you wish to edit already contains a translation this
translation will put into the edit buffer, too, and marked accordingly.
I've prepared another function to edit those translation variants using
ediff.  I can send or post a pre-release po-mode.el on request.  Here's
the code:

(define-key po-mode-map "l" 'po-lookup-compendium)

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

(defun po-lookup-compendium ()
  "Lookup `po-compendium-file' for a translation."
  (interactive)
  (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))
	start end)
    (if (null po-compendium-file)
	(error "No compendium file set; check `po-compendium-file'")
      (po-find-span-of-entry)
      (setq start po-start-of-entry
	    end po-start-of-msgstr)
      (save-current-buffer
	(set-buffer (get-buffer-create " *po-lookup"))
	(setq buffer-read-only nil)
	(erase-buffer)
	(insert-buffer-substring oldbuf start end)
	(insert "msgstr \"\"\n")
	(call-process-region (point-min) (point-max) "msgmerge" t t t
			     "-C" (expand-file-name po-compendium-file)
			     null-device "-q" "-o" "-" "-")
	(po-mode)
	(po-kill-ring-save-msgstr))
      (po-edit-msgstr)
      (if (looking-at "[#<]")
	  ;; edit buffer is empty; just yank
	  (progn (yank)
		 (if (looking-at "#")
		     (insert "\n")))
	(save-excursion
	  (insert "\n#-#-#-#-#  old translation  #-#-#-#-#\n"))
	(yank)))))

-- 
ke@suse.de (work) / keichwa@gmx.net (home):              |
http://www.suse.de/~ke/                                  |      ,__o
Free Translation Project:                                |    _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/             |   (*)/'(*)



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