i18nInfo['/'] ?? null; } /** * Get the I18nInfo that will be used to localize an element attribute value with the name * $name or null, if non-existent. * @param string $name * @return I18nInfo|null */ public function getAttributeInfo( string $name ): ?I18nInfo { return $this->i18nInfo[$name] ?? null; } /** * Get the name of the localized attributes or an empty array if no localized attributes * @return array */ public function getAttributeNames(): array { $res = []; foreach ( $this->i18nInfo as $k => $v ) { if ( $k !== '/' ) { $res[] = $k; } } return $res; } /** * Defines the internationalization parameters of a string contained in a span. */ public function setSpanInfo( I18nInfo $info ) { $this->i18nInfo['/'] = $info; } /** * Defines the internationalization parameters of the $name attribute's value. */ public function setAttributeInfo( string $name, I18nInfo $info ) { $this->i18nInfo[$name] = $info; } public function jsonSerialize(): array { return $this->i18nInfo; } public static function fromJson( array $json ): DataMwI18n { $i18n = new DataMwI18n(); foreach ( $json as $k => $v ) { $i18n->i18nInfo[$k] = new I18nInfo( $v['lang'], $v['key'], $v['params'] ); } return $i18n; } }