# wplingua/2.13.1/inc/dom/translate-node-texts.php

Translate and Go multilingual – Automatic AI translation – wpLingua, version 2.13.1. 58 lines.

- Page: https://pluginprobe.com/plugins/wplingua/2.13.1/code/inc/dom/translate-node-texts.php
- Raw: https://pluginprobe.com/plugins/wplingua/2.13.1/raw/inc/dom/translate-node-texts.php
- Modified: 2026-05-28T00:17:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wplingua/2.13.1/code/inc/dom/translate-node-texts.php#L10-L20`.

```php
<?php

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}


/**
 * Translate nodes text in dom for translated pages
 *
 * @param object $dom
 * @param array  $args
 * @return object
 */
function wplng_dom_translate_nodes_texts( $dom, $args ) {

	wplng_args_setup( $args );

	if ( empty( $args['translations'] )
		|| $args['load'] === 'progress'
	) {
		return $dom;
	}

	$selector = 'text';

	if ( $args['mode'] === 'editor'
		|| $args['mode'] === 'list'
	) {
		$selector = 'head text';
	}

	$node_text_excluded = wplng_data_excluded_node_text();

	foreach ( $dom->find( $selector ) as $element ) {

		if ( in_array( $element->parent->tag, $node_text_excluded ) ) {
			continue;
		}

		$text = wplng_text_esc( $element->innertext );

		if ( ! wplng_text_is_translatable( $text ) ) {
			continue;
		}

		$translated_text = wplng_get_translated_text_from_translations(
			$text,
			$args['translations']
		);

		$element->innertext = esc_html( $translated_text );
	}

	return $dom;
}

```
