How to make git consider .strings files as text file instead of binary file
After trying Jonathan or Slawomir's solution, I am still not able to see the diff properly. They are still being considered as binary file.
I finally figure out that the our localizable.strings file are not in UTF-8 encoding but in UTF-16 encoding. After changing the encoding back to UTF-8, it works fine.
Is it okay to change the encoding? Yes, it is. It is actually recommended by Apple to use UTF-8.
Note: It is recommended that you save strings files using the UTF-8 encoding, which is the default encoding for standard strings files. Xcode automatically transcodes strings files from UTF-8 to UTF-16 when they’re copied into the product.
[reference]
How do you know what encoding that file is? See this for command line and this for Xcode:
file -I vol34.tex
See comments below, you may have to change the encoding of the file manually:
iconv -f UTF-16 -t UTF8 file.strings
None of the solutions worked for me, so I did some more research and at this link I found out this:
in your project main directory, create or edit a .gitattributes file adding this line:
*.strings diff=localizablestrings
in the .gitconfig file in your home directory, add these lines:
[diff "localizablestrings"] textconv = "iconv -f utf-16 -t utf-8"
This did the trick.
Please add in your project root directory file .gitattributes
with content:
*.strings text
Now git will recognize your files .strings
as text files.
Create a .gitattributes
file at the root of your repo with this contents:
*.strings diff
More information: https://git-scm.com/docs/gitattributes