WP_Theme_JSON_Resolver::translate_theme_json_chunk( array $array_to_translate, string $key, string $context, string $domain )

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Translates a chunk of the loaded theme.json structure.

Parameters

$array_to_translate

(array) (Required) The chunk of theme.json to translate.

$key

(string) (Required) The key of the field that contains the string to translate.

$context

(string) (Required) The context to apply in the translation call.

$domain

(string) (Required) Text domain. Unique identifier for retrieving translated strings.

Return

(array) Returns the modified $theme_json chunk.

Source

File: wp-includes/class-wp-theme-json-resolver.php

private static function translate_theme_json_chunk( array $array_to_translate, $key, $context, $domain ) {
		foreach ( $array_to_translate as $item_key => $item_to_translate ) {
			if ( empty( $item_to_translate[ $key ] ) ) {
				continue;
			}

			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralContext,WordPress.WP.I18n.NonSingularStringLiteralDomain
			$array_to_translate[ $item_key ][ $key ] = translate_with_gettext_context( $array_to_translate[ $item_key ][ $key ], $context, $domain );
		}

		return $array_to_translate;
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/translate_theme_json_chunk