Gettext .po files under version control

A simple fix would be to apply a grep filter to remove comment metadata from the viewed diff. You can either do this to the output of the version control diff utility:

myVersionControl diff REV1 REV2 filea | grep -v '^..#'

or you may be able to instruct the version control diff utility to ignore these before it makes the comparison, which will likely result in a more reliable and prettier output:

I don’t know what version control system you use, but git (for example) allows you to preprocess the input to diff and remove the comment lines for certain file types (thanks VonC), see man gitattributes and search for Performing text diffs of binary files. Here’s the body of a sample script to save as /usr/local/bin/strippocomments which will do that:

grep -v '^#:' $1

You can then tell git to use this script to preprocess po files, by adding the following to the file .git/info/attributes in your repository:

*.po diff=podiff

and to the file .git/config in your repository:

[diff "podiff"]
    textconv = /usr/local/bin/strippocomments

Using git diff should then not include any lines starting with #:.

Note that the diffs generated from git diff using this approach should not be used for patching – but git format-patch will still use the default diff, so patches generated for emailing will still be ok.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)