12 use InvalidArgumentException;
53 public function __construct($lang =
"en-US", $xmlString =
null)
55 $this->language = $lang;
57 if (!empty($xmlString)) {
58 $this->localeXml =
new SimpleXMLElement($xmlString);
64 $this->parseXml($this->localeXml);
71 public function addXml(SimpleXMLElement $xml)
73 $lang = (string) $xml->attributes(
'http://www.w3.org/XML/1998/namespace')->{
'lang'};
75 $this->parseXml($xml);
85 return $this->language;
94 public function filter($type, $name, $form =
"long")
96 if (!isset($this->{$type})) {
97 throw new InvalidArgumentException(
"There is no locale of type \"$type\".");
101 $localeList = $this->{$type};
103 if (is_null($name)) {
108 $array = $localeList->get($name);
111 $ret =
new stdClass();
114 $ret->multiple =
null;
119 if ($type !==
"options") {
121 $array = array_filter($array,
function ($term) use ($form) {
122 return $term->form === $form;
126 return array_pop($array);