public static function extractLocalizedStrings(\DOMElement $parent, string $namespaceURI, string $localName) : array
    {
        $ret = [];
        foreach ($parent->childNodes as $node) {
            if ($node->namespaceURI !== $namespaceURI || $node->localName !== $localName) {
                continue;
            } else if (!($node instanceof DOMElement)) {
                continue;
            }

            if ($node->hasAttribute('xml:lang')) {
                $language = $node->getAttribute('xml:lang');
            } else {
                $language = 'en';
            }
            $ret[$language] = trim($node->textContent);
        }

        return $ret;
    }
public static function extractLocalizedStrings(\DOMElement $parent, string $namespaceURI, string $localName) : array
    {
        $ret = [];
        foreach ($parent->childNodes as $node) {
            if ($node->namespaceURI !== $namespaceURI || $node->localName !== $localName) {
                continue;
            } else if (!($node instanceof DOMElement)) {
                continue;
            }

            if ($node->hasAttribute('xml:lang')) {
                $language = $node->getAttribute('xml:lang');
            } else {
                $language = 'en';
            }
            $ret[$language] = trim($node->textContent);
        }

        return $ret;
    }
public static function extractLocalizedStrings ( \ DOMElement $ parent , string $ namespaceURI , string $ localName ) : array { $ ret = [ ] ; foreach ( $ parent -> childNodes as $ node ) { if ( $ node -> namespaceURI !== $ namespaceURI || $ node -> localName !== $ localName ) { continue ; } else if ( ! ( $ node instanceof DOMElement ) ) { continue ; } if ( $ node -> hasAttribute ( 'xml:lang' ) ) { $ language = $ node -> getAttribute ( 'xml:lang' ) ; } else { $ language = 'en' ; } $ ret [ $ language ] = trim ( $ node -> textContent ) ; } return $ ret ; }
Extract localized strings from a set of nodes.

@param \DOMElement $parent The element that contains the localized strings.
@param string $namespaceURI The namespace URI the localized strings should have.
@param string $localName The localName of the localized strings.
@return array Localized strings.
Extract localized strings from a set of nodes .