Example #1
0
 /**
  * @return LocoLocale
  */
 public static function init($lc, $cc)
 {
     extract(self::data());
     if (!$cc) {
         $cc = loco_language_country($lc);
     }
     $label = '';
     $locale = new LocoLocale($lc, $cc);
     // attempt to use a common locale combination
     if (isset($locales[$lc])) {
         if (!$cc) {
             $cc = key($locales[$lc]);
             $locale->region = $cc;
         }
         if (isset($locales[$lc][$cc])) {
             $locale->label = $locales[$lc][$cc];
         }
     }
     // get plural rules from iso 639 language and set label if common locale wasn't known
     if (isset($langs[$lc])) {
         list($label, $pluraleq, $plurals) = $langs[$lc];
         $locale->pluraleq = $pluraleq;
         $locale->plurals = $plurals;
         $locale->nplurals = count($plurals);
     }
     // get country just for label if not already applied from common locale combo
     if (!$locale->label) {
         if ($cc) {
             if (isset($regions[$cc])) {
                 $label = $label ? $label . ' (' . $regions[$cc] . ')' : $regions[$cc];
             } else {
                 $label = $label ? $label . ' (' . $cc . ')' : '';
             }
         }
         $locale->label = $label;
     }
     return $locale;
 }
Example #2
0
 /**
  * Alias to loco_language_country
  */
 public static function default_region($lang)
 {
     self::data();
     if ('en' === $lang) {
         return 'US';
     }
     return loco_language_country($lang);
 }