Fixing mkv files

I have a bunch of mkv files with foreign audio, but the subtitle track doesn’t have a language set, so Plex doesn’t know it should auto-select the subtitles.
I finally found a solution: Good ol’ mkvtoolnix, or mkvpropedit to be exact.

Just run this in the folder with the offending files:

for file in $(ls *mkv); do 
    mkvpropedit $file --edit track:s1 --set language=en; 

This sets the language of the first subtitle track to english.

See also the official docs