question: protected String resolveLanguage ( List < DetectedLanguage > languages , String fallbackLang ) { String langStr ; if ( languages . size ( ) == 0 ) { log . debug ( "No language detected, using fallback {}" , fallbackLang ) ; langStr = fallbackLang ; } else { DetectedLanguage lang = languages . get ( 0 ) ; String normalizedLang = normalizeLangCode ( lang . getLangCode ( ) ) ; if ( langWhitelist . isEmpty ( ) || langWhitelist . contains ( normalizedLang ) ) { log . debug ( "Language detected {} with certainty {}" , normalizedLang , lang . getCertainty ( ) ) ; if ( lang . getCertainty ( ) >= threshold ) { langStr = normalizedLang ; } else { log . debug ( "Detected language below threshold {}, using fallback {}" , threshold , fallbackLang ) ; langStr = fallbackLang ; } } else { log . debug ( "Detected a language not in whitelist ({}), using fallback {}" , lang . getLangCode ( ) , fallbackLang ) ; langStr = fallbackLang ; } } if ( langStr == null || langStr . length ( ) == 0 ) { log . warn ( "Language resolved to null or empty string. Fallback not configured?" ) ; langStr = "" ; } return langStr ; }
target:  Chooses a language based on the list of candidates detected