Skip to content

Instantly share code, notes, and snippets.

@asmallteapot
Last active March 31, 2022 11:43
Show Gist options
  • Save asmallteapot/11227602 to your computer and use it in GitHub Desktop.
Save asmallteapot/11227602 to your computer and use it in GitHub Desktop.
Diff Xcode localizable strings files in Git.
*.strings utf16 diff=localizablestrings
[diff "localizablestrings"]
textconv = "iconv -f utf-16 -t utf-8"
binary = false

Git v1.8.4 has no idea how to diff Xcode .strings files. Here's how to fix that:

  1. Add the bit from .gitconfig to your ~/.gitconfig.
  2. Add the bit from .gitattributes to your project's .gitattributes file. This should be at the root of your project, if one doesn't already exist.
  3. You should now be able to use git diff and git add -p with strings files.

The conversion seems to cause rendering issues for some non-Latin characters in iTerm2 v1.0.0.20140112 on Mac OS 10.9.2, but this doesn't affect the files themselves. If anyone knows how to fix this issue, please add a comment.

@xieweiAlex
Copy link

I met the same problem. I fixed it by changing the text encoding of Localizable.strings from No explicit Encoding to UTF-16, everything works fine now.

@kerrmarin
Copy link

@shyambhat did you ever get this working on GitHub?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment