Coding standards
Security in ResourceSpace
Developer reference
Database
User api session functions
Geolocation functions
Storage test functions
Cli functions
Lang translation functions

lang_translation_restore_html()

Description

Restore original HTML when a response preserves the complete marker sequence.
Invalid responses remain intact for the regular translation validator to reject.

Parameters

ColumnTypeDefaultDescription
$source mixed English source value.
$candidate: mixed
$candidate mixed Translated value containing markers.

Return

mixed Candidate with any preserved HTML restored.

Location

include/lang_translation_functions.php lines 79 to 98

Definition

 
function lang_translation_restore_html(mixed $source, mixed $candidate): mixed
{
    if (
is_array($source) && is_array($candidate)) {
        foreach (
array_intersect_key($source, $candidate) as $key => $value) {
            
$candidate[$key] = lang_translation_restore_html($value, $candidate[$key]);
        }
        return 
$candidate;
    }
    if (!
is_string($source) || !is_string($candidate)) {
        return 
$candidate;
    }

    
lang_translation_mask_html($source, $tags);
    if (
$tags === []) {
        return 
$candidate;
    }

    
preg_match_all(LANG_TRANSLATION_HTML_MARKER, $candidate, $markers);
    return 
$markers[0] === array_keys($tags) ? strtr($candidate, $tags) : $candidate;
}

This article was last updated 27th November 2026 18:35 Europe/London time based on the source file dated 27th November 2026 17:15 Europe/London time.