Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Last active April 10, 2023 06:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephenharris/3c3792568494b2a7cf48 to your computer and use it in GitHub Desktop.
Save stephenharris/3c3792568494b2a7cf48 to your computer and use it in GitHub Desktop.
Suppressing comments from git diff of .po files

How to suppress comments when performing git diff on .po files.

Taken from: http://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control

Changes in the codebase can alter line numberings given in .po 'comments'. While such changes should be committed they make obsecure the actual translation changes made, and make auditing them difficult.

  1. Create /usr/local/bin/strippocomments as given in this gist.

  2. Set up pre-processing of .po files by editing .git/info/attributes and adding:

     *.po diff=podiff
    
  3. Edit .git/config and add the line

     [diff "podiff"]
         textconv = /usr/local/bin/strippocomments
    
grep -vE '^#:|POT-Creation-Date' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment