Habari\Locale::translate_xml PHP Метод

translate_xml() публичный статический Метод

Return a translated value of a SimpleXml object value based on the locale and namespace
public static translate_xml ( SimpleXMLElement $parent, SimpleXMLElement $child, string $ns = 'http://www.w3.org/XML/1998/namespace', null | string $locale = null )
$parent SimpleXMLElement The parent node of the node we are translating
$child SimpleXMLElement The child node we're trying to translate
$ns string The namespace to use for the lang attribute of the node to be translated
$locale null | string The locale we want to translate into
    public static function translate_xml(\SimpleXMLElement $parent, \SimpleXMLElement $child, $ns = 'http://www.w3.org/XML/1998/namespace', $locale = null)
    {
        $use = null;
        // Set the locale
        if (!isset($locale)) {
            $locale = self::$locale;
        }
        // Loop through the child elements
        foreach ($child as $el) {
            if (isset($el['lang']) && $el['lang'] == $locale) {
                // If a translation for the element is found, use it instead of the default value
                // Remove the lang attribute in memory to make it the default
                unset($el['lang']);
            }
        }
    }