Package: vim-scripts Version: 20091011 Severity: wishlist Tags: patch Hello,
I tried to contact the upstream author regarding this patch, but I got no response. The diff part needs more work. [sniped irrelevant system info] Thanks, Andrei
--- /usr/share/vim-scripts/ftplugin/po.vim 2009-10-11 19:24:05.000000000 +0300 +++ .vim/ftplugin/po.vim 2011-01-30 17:39:35.000000000 +0200 @@ -1,8 +1,8 @@ " Vim ftplugin for PO file (GNU gettext) editing. " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com> -" Last Change: Tue, 12 Apr 2005 13:49:55 -0400 +" Last Change: Tue, 30 Jan 2011 17:25:32 +0200 " -" *** Latest version: http://www.vim.org/scripts/script.php?script_id=695 *** +" *** Based on the version at: http://www.vim.org/scripts/script.php?script_id=695 *** " " DESCRIPTION " This file is a Vim ftplugin for editing PO files (GNU gettext -- the GNU @@ -19,7 +19,7 @@ " Move to the next fuzzy translation <S-F5> \f " Move to the previous fuzzy translation <S-F6> \b " Label the translation fuzzy <S-F7> \z -" Remove the fuzzy label <S-F8> \r +" Remove the fuzzy label and previous msgid <S-F8> \r " Show msgfmt statistics for the file(*) <S-F11> \s " Browse through msgfmt errors for the file(*) <S-F12> \e " Put the translator info in the header \t \t @@ -36,7 +36,7 @@ " Move to the next fuzzy translation <S-F5> \f " Move to the previous fuzzy translation <S-F6> \b " Label the translation fuzzy <S-F7> \z -" Remove the fuzzy label <S-F8> \r +" Remove the fuzzy label and previous msgid <S-F8> \r " Split-open the file under cursor gf gf " Show msgfmt statistics for the file(*) <S-F11> \s " Browse through msgfmt errors for the file(*) <S-F12> \e @@ -45,6 +45,10 @@ " --------------------------------------------------------------- " (*) Only available on UNIX computers. " +" Command +" =============================================================== +" Use a hidden buffer to highlight changes :DiffMsgid +" " Remarks: " - "S" in the above key mappings stands for the <Shift> key and "\" in " fact means "<LocalLeader>" (:help <LocalLeader>), which is "\" by @@ -69,6 +73,10 @@ " program via the global variable 'g:po_msgfmt_args'. All arguments are " allowed except the "-o" for output file. The default value is " "-vv -c". +" - The :DiffMsgid command works only if --previous was used with msgmerge +" (or equivalent options in other .po tools). +" TODO +" The substitute does not work for strings that are only one line " " But there's even more! " @@ -212,7 +220,7 @@ endwhile endf -" Remove fuzzy description from the translation. +" Remove previous msgid and fuzzy flag. if !hasmapto('<Plug>RemoveFuzzy') if gui imap <buffer> <unique> <S-F8> <Plug>RemoveFuzzy @@ -222,16 +230,12 @@ nmap <buffer> <unique> <LocalLeader>r <Plug>RemoveFuzzy endif endif -inoremap <buffer> <unique> <Plug>RemoveFuzzy <ESC>{vap:call <SID>RemoveFuzzy()<CR>i -nnoremap <buffer> <unique> <Plug>RemoveFuzzy {vap:call <SID>RemoveFuzzy()<CR> +inoremap <buffer> <unique> <Plug>RemoveFuzzy <ESC>{vap:call <SID>RemoveFuzzy()<CR>gv<ESC>}i +nnoremap <buffer> <unique> <Plug>RemoveFuzzy {vap:call <SID>RemoveFuzzy()<CR>gv<ESC>} -fu! <SID>RemoveFuzzy() - let line = getline(".") - if line =~ '^#,\s*fuzzy$' - exe "normal! dd" - elseif line =~ '^#,\(.*,\)\=\s*fuzzy' - exe 's/,\s*fuzzy//' - endif +fu! <SID>RemoveFuzzy() range + execute ':''<,''>global/^#,\sfuzzy$\|^#|\s.*".*"$/d' + execute ':''<,''>s/,\s*fuzzy//e' endf " Show PO translation statistics. (Only available on UNIX computers for now.) @@ -404,4 +408,33 @@ endif endf +" This copies everything to a new, hidden buffer, so we can use the builtin +" diff capabilities of vim. Built on an idea of Jürgen Krämer from the vim +" users mailing list +fu! DiffPreviousString() + %yank + new + put! + " this replaces the current msgid with the old one, so that diff + " can highlight the changes. Currently doesn't work with + " msgids that are only in one (the first) line + " example: + " ------------------------ + " #, fuzzy + " #| msgid "previous text" + " msgid "new text" + " msgstr "translation" + " + " ------------------------ + %s/^\(#| msgid ""\n\(\_.\{-\}\n\)msgid ""\n\)\(\_.\{-\}\n\)\(msgstr ""\)/\=submatch(1).substitute(submatch(2), '#| ', '', 'g').submatch(4)/ + nohls + diffthis + hide + diffthis + set fdc=0 + set nofen +endf + +command DiffMsgid call DiffPreviousString() + unlet gui