Automattic\WooCommerce\Vendor\Symfony\Component\CssSelector\XPath\Extension

HtmlExtension::translateLangpublicWC 1.0

Method of the class: HtmlExtension{}

No Hooks.

Returns

null. Nothing (null).

Usage

$HtmlExtension = new HtmlExtension();
$HtmlExtension->translateLang( $xpath, $function ): XPathExpr;
$xpath(XPathExpr) (required)
.
$function(FunctionNode) (required)
.

HtmlExtension::translateLang() code WC 10.5.0

public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
{
    $arguments = $function->getArguments();
    foreach ($arguments as $token) {
        if (!($token->isString() || $token->isIdentifier())) {
            throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
        }
    }

    return $xpath->addCondition(sprintf(
        'ancestor-or-self::*[@lang][1][starts-with(concat('
        ."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
        .', %s)]',
        'lang',
        Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-')
    ));
}