Elgg  Version 2.3
Locale.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\I18n;
3 
13 final class Locale {
14 
16  private $locale;
17 
23  private function __construct($locale) {
24  $this->locale = $locale;
25  }
26 
28  public function __toString() {
29  return $this->locale;
30  }
31 
41  public static function parse($locale) {
42  // TODO(evan): Better sanitizing of locales using \Locale perhaps
43  if (!preg_match('~^[a-z0-9_]{2,20}$~', $locale)) {
44  throw new InvalidLocaleException("Unrecognized locale: $locale");
45  }
46 
47  return new Locale($locale);
48  }
49 }
static parse($locale)
Create a language, asserting that the language code is valid.
Definition: Locale.php:41
WARNING: API IN FLUX.
Definition: Locale.php:13
Indicated an invalid Locale was given.