Wednesday, June 30, 2010

Re: vimdiff-like highlighting within the same file?

Hi,

Andrei Popescu wrote:
> On Mi, 30 iun 10, 13:32:22, Marc Weber wrote:
>>
>> Can't you just provide two files? The old and the new one? Most VCS
>> systems do that anyway
>
> vimdiff can be used (but it's not ideal) if you have access to the
> previous .po file, but this is not always the case. Especially bigger
> projects will only provide .po files through some web interface.
>
>> #| msgid ""
>> #| "The following disk access storage devices (DASD) are available. Please "
>> #| "select each device you want to use one at a time."
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ old English msgid
>>
>> You can get rid of those comments: :g/^$|/d
>> Then you can diff old and new files directly
>
> Not really. The workflow is like this (best illustrated with a sample):
>
> #: ../file.c: 123
> msgid "translatable string"
> msgstr "translation of the string"
>
> 1. programmer changes the translatable string in the program source code
> and uses automated tools to update the .po. During this update the
> changed msgid is completely replaced with the new one (might involve
> wrapping changes)
> 2. fuzzy flag is set for the respective string
> 3. (optional) for the benefit of translators the old msgid is *added* to
> the file and marked as such with the '#|'
>
> #: ../file.c: 123
> #, fuzzy
> #| msgid "translatable string"
> msgid ""
> "This is the new translatable string, too big to fit on one line, which"
> "is why the line is wrapped"
> msgstr "translation of the string"
>
> a) the translator opens the new .po file and updates the translation
> b) removes fuzzy flag (and the previous msgid if present) to indicate
> that the translation is now ok
>
> #: ../file.c: 123
> msgid ""
> "This is the new translatable string, too big to fit on one line, which"
> "is why the line is wrapped"
> msgstr ""
> "new translation ....................................................."
> "................................................."
>
>
> (of course, this example shows a big change, were highlighting the
> changes is rather unnecessary, but I think you get the point and why the
> usual diff tools are not very useful)

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
:wincmd w
:diffthis

Modifications are now highlighted in the new string -- but not in the old
string.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment