public static function getByCountry($country)
 {
     if (isset(self::$list[$country])) {
         $divisions = self::$list[$country];
         // Localize subdivisions where possible
         if (isset(self::$keyBase[$country])) {
             foreach ($divisions as $abbr => $name) {
                 $key = self::$keyBase[$country] . $abbr;
                 if (WmfFramework::messageExists($key)) {
                     $divisions[$abbr] = WmfFramework::formatMessage($key);
                 }
             }
         }
         return $divisions;
     }
     return false;
 }
 /**
  * languageSpecificFallback - returns the text of the first existant message
  * in the requested language. If no messages are found in that language, the
  * function returns the first existant fallback message.
  *
  * @param string $language the code of the requested language
  * @param array $msg_keys
  * @param array $params extra message parameters
  * @throws InvalidArgumentException
  * @return String the text of the first existant message
  */
 public static function languageSpecificFallback($language = 'en', $msg_keys = array(), $params = array())
 {
     if (count($msg_keys) < 1) {
         throw new InvalidArgumentException(__FUNCTION__ . " BAD PROGRAMMER. No message keys given.");
     }
     # look for the first message that exists
     foreach ($msg_keys as $m) {
         if (WmfFramework::messageExists($m, $language)) {
             return WmfFramework::formatMessage($m, $params);
         }
     }
     # we found nothing in the requested language, return the first fallback message that exists
     foreach ($msg_keys as $m) {
         if (WmfFramework::messageExists($m, $language)) {
             return WmfFramework::formatMessage($m, $params);
         }
     }
     # somehow we still don't have a message, return a default error message
     return WmfFramework::formatMessage($msg_keys[0], $params);
 }
 /**
  * getErrorMessage - returns the translated error message appropriate for a
  * validation error on the specified field, of the specified type.
  * @param string $field - The common name of the field containing the data
  * that is causing the error.
  * @param string $type - The type of error being caused, from a set.
  *    Possible values are:
  *        'not_empty' - the value is required and not currently present
  *        'valid_type' - in general, the wrong format
  *        'calculated' - fields that failed some kind of multiple-field data
  * integrity check.
  * @param string $language MediaWiki language code
  * @param string $country ISO country code
  * @return String
  */
 public static function getErrorMessage($field, $type, $language, $country = null)
 {
     //this is gonna get ugly up in here.
     //error_log( __FUNCTION__ . " $field, $type, $value " );
     //NOTE: We are just using the next bit because it's convenient.
     //getErrorToken is actually for something entirely different:
     //Figuring out where on the form the error should land.
     $message_field = self::getErrorToken($field);
     if ($field === 'expiration') {
         ///the inevitable special case.
         $message_field = $field;
     }
     //postal code is a weird one. More L10n than I18n.
     //'donate_interface-error-msg-postal' => 'postal code',
     $error_message_field_key = 'donate_interface-error-msg-' . $message_field;
     if ($country !== null) {
         $translated_field_name = MessageUtils::getCountrySpecificMessage($error_message_field_key, $country, $language);
     } else {
         if (WmfFramework::messageExists($error_message_field_key, $language)) {
             $translated_field_name = WmfFramework::formatMessage($error_message_field_key);
         } else {
             $translated_field_name = false;
         }
     }
     //Empty messages should get:
     //'donate_interface-error-msg' => 'Please enter your $1';
     //If they have no defined error message, give 'em the default.
     if ($type === 'not_empty') {
         if ($message_field != 'general' && $translated_field_name) {
             return WmfFramework::formatMessage('donate_interface-error-msg', $translated_field_name);
         }
     }
     if ($type === 'valid_type' || $type === 'calculated') {
         //NOTE: We are just using the next bit because it's convenient.
         //getErrorToken is actually for something entirely different:
         //Figuring out where on the form the error should land.
         $token = self::getErrorToken($field);
         $error_key_calc = 'donate_interface-error-msg-' . $token . '-calc';
         if ($type === 'calculated') {
             // try for the special "calculated" error message.
             if (WmfFramework::messageExists($error_key_calc, $language)) {
                 return WmfFramework::formatMessage($error_key_calc);
             }
         }
         //try for new more specific default correction message
         if ($message_field != 'general' && $translated_field_name && WmfFramework::messageExists('donate_interface-error-msg-field-correction', $language)) {
             return WmfFramework::formatMessage('donate_interface-error-msg-field-correction', $translated_field_name);
         }
     }
     //ultimate defaultness.
     return WmfFramework::formatMessage('donate_interface-error-msg-general');
 }