summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2021-05-26 17:57:41 -0500
committersfan5 <sfan5@live.de>2023-06-25 11:01:58 +0200
commit76009bf7a6192b9eddc8d4c21a17133bf6352b2b (patch)
treec15b47b20252f89459873d39d5de605ef003c782 /player
parenteb14dbff3e3aeaccd4172b1b3139966e45e223b4 (diff)
downloadmpv-76009bf7a6192b9eddc8d4c21a17133bf6352b2b.tar.bz2
mpv-76009bf7a6192b9eddc8d4c21a17133bf6352b2b.tar.xz
loadfile: use mp_match_lang_single
This adds basic support for IETF language tags, as well as matching 2-letter language codes against 3-letter ones (and vice versa).
Diffstat (limited to 'player')
-rw-r--r--player/loadfile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 009d1471ad..5095f6a49f 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -47,6 +47,7 @@
#include "common/recorder.h"
#include "common/stats.h"
#include "input/input.h"
+#include "misc/language.h"
#include "audio/out/ao.h"
#include "filters/f_decoder_wrapper.h"
@@ -447,8 +448,9 @@ static int match_lang(char **langs, const char *lang)
if (!lang)
return 0;
for (int idx = 0; langs && langs[idx]; idx++) {
- if (lang && strcasecmp(langs[idx], lang) == 0)
- return INT_MAX - idx;
+ int score = mp_match_lang_single(langs[idx], lang);
+ if (score > 0)
+ return INT_MAX - (idx + 1) * LANGUAGE_SCORE_MAX + score - 1;
}
return 0;
}