aesefficio / BellsAndWhistlesMod

https://aesefficio.github.io/BellsAndWhistlesMod/
GNU General Public License v3.0
6 stars 7 forks source link

Add fr_fr.json and es_es.json. Configure Git to manage line endings #25

Open kkempfer opened 7 months ago

kkempfer commented 7 months ago

Following your call on Curseforge and Modrinth, I added a translation of your mod in French and Spanish. Similar to @AsseyGithub, @avirtual777, @BesrezenUs, I only updated the default branch 1.20.1-forge.

I noticed some formatting issues in the different JSON files. If you want, I can format them all for you.

a0a7 commented 7 months ago

Yessssiiiir thank you so much! Really really appreciated. I will go ahead and pull this into all branches,

What are the formatting issues you've identified? If you want to fix it that would be awesome, but only do so if you're willing!

kkempfer commented 7 months ago

Git configuration: Line endings

Your git repo is not configured to handle Windows-style line endings. Some developers may use Windows OS. Without a proper configuration, this could break your code in the long run.

GitHub Doc: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings More info: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/

I detected the problem in the first place by using this command to find all the files in your repo containing the Windows-style line endings patterns. There was only one file concerned, zh_cn.json, so no big deal since it's only a JSON file.

$ find -type f -exec grep -c --color=never $'\r' {} + | grep -v ":0"
...
./src/main/resources/assets/bellsandwhistles/lang/zh_cn.json:40
...
$ cat -e ./src/main/resources/assets/bellsandwhistles/lang/zh_cn.json | head -n 2
{^M$
    "block.bellsandwhistles.andesite_grab_rails": "M-eM-.M-^IM-eM-1M-1M-fM-^IM-6M-fM-^IM-^KM-fM-^]M-^F",^M$

I filtered out the binary files we do not want to modify (PNG, PDN and WEBP) and adjusted the .gitattributes file accordingly. Then, I ran the commands below to automatically fix and updates all the files.

$ git add --renormalize .
$ git rm -rf --cached .
$ git reset --hard HEAD
$ git commit -m "Normalize all the line endings"
$ git push

Now, your git repo is properly configured for any developer using any OS, independently of their local git configuration.

Pretty JSON

I formatted all the JSON files in the lang directory with jq to make them easier to compare.

for filepath in $(find -name "*.json"); do cat $filepath | jq > $filepath.tmp && mv $filepath.tmp $filepath; done

FYI, the ko_kr.json translation is incomplete, but I can't help you with this one. Maybe @AsseyGithub could give it a shot.

Cheers