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

lang_translation_results()

Description

Separate accepted entries from those needing another attempt.

Parameters

ColumnTypeDefaultDescription
$batch array Requested English entries.
$candidate: mixed
! $batch
$candidate mixed Decoded response.

Return

array{accepted: array, rejected: array<string, string>} Validated entries and failure reasons.

Location

include/lang_translation_functions.php lines 328 to 347

Definition

 
function lang_translation_results(array $batch, mixed $candidate): array
{
    
$accepted = [];
    
$rejected = [];
    if (!
is_array($candidate) || array_diff_key($candidate, $batch) !== []) {
        return [
'accepted' => [], 'rejected' => array_fill_keys(array_keys($batch), 'unexpected response shape')];
    }
    foreach (
$batch as $key => $source) {
        
$translation = lang_translation_restore_html($source, $candidate[$key] ?? null);
        
$issue = array_key_exists($key, $candidate)
            ? 
lang_translation_issue($source, $translation)
            : 
'missing key';
        if (
$issue === null) {
            
$accepted[$key] = lang_translation_order($source, $translation);
        } else {
            
$rejected[$key] = $issue;
        }
    }
    return [
'accepted' => $accepted, 'rejected' => $rejected];
}

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.