/**
  * Returns the given locale, if it is in the list of supported locales.
  * Otherwise, tries extracting the language portion of it (e.g: 'en' from
  * 'en_US') and return it if it is in the list of supported locales.
  * If nothing matches, returns the default locale.
  *
  * @param String $locale
  */
 public static function getSupportedLocale($locale)
 {
     $supported_locales = self::$translator->getAvailableLocales();
     if (in_array($locale, $supported_locales)) {
         return $locale;
     }
     $user_locale = explode('_', $locale);
     if (in_array($user_locale[0], $supported_locales)) {
         return $user_locale[0];
     }
     return Config::getInstance()->getString('webapp/defaultLocale', 'en');
 }