Elgg  Version 1.11
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 (strlen($locale) < 2 || strlen($locale) > 5) {
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