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

Re: po editor which makes use of "previous" feature



On Du, 23 ian 11, 08:21:39, Tobias Quathamer wrote:
> 
> for about one and a half years, gettext can add the previous content of
> a msgid in the automatic comments. This can ease the work of
> translators, because you're able to directly compare the old and new
> msgid and spot the difference.
... 
> Does anyone know of an editor with such features? Or does anyone know if
> this is being worked on?

I've been working on a solution for vim. There are two things to 
support:

Highlighting of differences
---------------------------

See this thread on googlegroups:
http://groups.google.com/group/vim_use/browse_thread/thread/cc8d2a76690a27dc#

Personally I like this solution (with two minor additions of my own):

On Mi, 30 iun 10, 15:42:37, Jürgen Krämer wrote:                                                                                                        
>                                                                                                                                                       
> maybe the following can be a start. Open your .po file and execute these                                                                              
> commands (the fourth command is one long line):                                                                                                       
>                                                                                                                                                       
>   :%y                                                                                                                                                 
>   :vert new                                                                                                                                           
>   :put!                                                                                                                                               
>   :%s/^\(#| msgid ""\n\(\_.\{-\}\n\)msgid ""\n\)\(\_.\{-\}\n\)\(msgstr ""\)/\=submatch(1).substitute(submatch(2), '#| ', '', 'g').submatch(4)/        
>   :nohls                                                                                                                                              
>   :diffthis                                                                                                                                           
    :set hidden                                                                                                                                         
>   :wincmd w                                                                                                                                           
    :wincmd o                                                                                                                                           
>   :diffthis                                                                                                                                           
>                                                                                                                                                       
> Modifications are now highlighted in the new string -- but not in the old                                                                             
> string.

Unfortunately at the time I lost interest in a proper implementation 
(most likely as a patch to the po.vim ftplugin), but know with the 
release notes I'll badly need this again.

Removing the previous string after unfuzzy-ing
----------------------------------------------

I have a patch for ftplugin/po.vim which I'm using (attached). I tried 
to contact the Author of the po.vim ftplugin for inclusion, but no 
answer.

Hope this helps some vim users,
Andrei
-- 
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
From 2e65201107f081051f0084ce1cd04a24a18ef512 Mon Sep 17 00:00:00 2001
From: Andrei Popescu <andreimpopescu@gmail.com>
Date: Tue, 1 Jun 2010 22:49:18 +0300
Subject: [PATCH] Remove previous msgid when removing fuzzy flag

---
 .vim/ftplugin/po.vim |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/.vim/ftplugin/po.vim b/.vim/ftplugin/po.vim
index 8b083ab..cb58494 100644
--- a/.vim/ftplugin/po.vim
+++ b/.vim/ftplugin/po.vim
@@ -1,6 +1,6 @@
 " 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, 01 Jun 2010 22:37:32 +0300
 "
 " *** Latest version: http://www.vim.org/scripts/script.php?script_id=695 ***
 "
@@ -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
@@ -182,7 +182,7 @@ endif
 inoremap <buffer> <unique> <Plug>PreviousFuzzy <ESC>{?^#,\(.*,\)\=\s*fuzzy<CR>:let @/=""<CR>:call histdel("/", -1)<CR>/^msgstr<CR>:let @/=""<CR>:call histdel("/", -1)<CR>z.$i
 nnoremap <buffer> <unique> <Plug>PreviousFuzzy {?^#,\(.*,\)\=\s*fuzzy<CR>:let @/=""<CR>:call histdel("/", -1)<CR>/^msgstr<CR>:let @/=""<CR>:call histdel("/", -1)<CR><C-L>z.$
 
-" Insert fuzzy description for the translation.
+" Insert fuzzy flag for the translation.
 if !hasmapto('<Plug>InsertFuzzy')
    if gui
       imap <buffer> <unique> <S-F7> <Plug>InsertFuzzy
@@ -212,7 +212,7 @@ fu! <SID>InsertFuzzy() range
    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 +222,12 @@ if !hasmapto('<Plug>RemoveFuzzy')
       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.)
-- 
1.7.1

Attachment: signature.asc
Description: Digital signature


Reply to: