/**
  * normalize helper function.
  * If the language has not yet been set or is not valid, pulls the language code
  * from the current global language object.
  */
 protected function setLanguage()
 {
     $language = false;
     if ($this->isSomething('uselang')) {
         $language = $this->getVal('uselang');
     } elseif ($this->isSomething('language')) {
         $language = $this->getVal('language');
     }
     if ($language) {
         $language = strtolower($language);
     }
     if ($language == false || !WmfFramework::isValidBuiltInLanguageCode($language)) {
         $language = WmfFramework::getLanguageCode();
     }
     $this->setVal('language', $language);
     $this->expunge('uselang');
 }
 /**
  * Returns a valid mediawiki language code to use for all the DonationInterface translations.
  *
  * Will only look at the currently configured language if the 'language' key
  * doesn't exist in the data set: Users may not have a language preference
  * set if we're bouncing between mediawiki instances for payments.
  * @param array $data A normalized DonationInterface data set.
  * @return string A valid mediawiki language code.
  */
 public static function guessLanguage($data)
 {
     if (array_key_exists('language', $data) && WmfFramework::isValidBuiltInLanguageCode($data['language'])) {
         return $data['language'];
     } else {
         return WmfFramework::getLanguageCode();
     }
 }