protected function find_language() {
        global $CFG;
        $this->language = current_language();
        $basedir = $CFG->dirroot . '/media/player/videojs/videojs/lang/';
        $langfiles = get_directory_list($basedir);
        $candidates = [];
        foreach ($langfiles as $langfile) {
            if (strtolower(pathinfo($langfile, PATHINFO_EXTENSION)) !== 'js') {
                continue;
            }
            $lang = basename($langfile, '.js');
            if (strtolower($langfile) === $this->language . '.js') {
                // Found an exact match for the language.
                $js = file_get_contents($basedir . $langfile);
                break;
            }
            if (substr($this->language, 0, 2) === strtolower(substr($langfile, 0, 2))) {
                // Not an exact match but similar, for example "pt_br" is similar to "pt".
                $candidates[$lang] = $langfile;
            }
        }
        if (empty($js) && $candidates) {
            // Exact match was not found, take the first candidate.
            $this->language = key($candidates);
            $js = file_get_contents($basedir . $candidates[$this->language]);
        }
        // Add it as a language for Video.JS.
        if (!empty($js)) {
            return "$js\n";
        }

        // Could not match, use default language of video player (English).
        $this->language = null;
        return "";
    }