function get_requestor_preferred_language() {
    // Check if the 'HTTP_ACCEPT_LANGUAGE' header is set
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        // Get the language preference list from the header
        $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        
        // Loop through the language preference list
        foreach ($languages as $lang) {
            // Extract the language code and quality value
            $lang = explode(';', $lang);
            $lang_code = trim($lang[0]);
            $quality = isset($lang[1]) ? (float) str_replace('q=', '', $lang[1]) : 1.0;
            
            // Check if the language code is one of the supported languages
            if (in_array($lang_code, ['es', 'de', 'en', 'fr', 'zh', 'jp'])) {
                // Return the language code if it is supported and has the highest quality value
                return $lang_code;
            }
        }
    }
    
    // Fallback to 'en' if no supported language was found
    return 'en';
}
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence