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

lang_translation_schema()

Description

Build the strict JSON shape for a pack value. Represent every PHP array as a keyed JSON object
so indexed and associative arrays both preserve their keys, including nested arrays.

Parameters

ColumnTypeDefaultDescription
$value: mixed
$value mixed English source value.

Return

array JSON Schema for the value.

Location

include/lang_translation_functions.php lines 15 to 33

Definition

 
function lang_translation_schema(mixed $value): array
{
    if (!
is_array($value)) {
        return [
'type' => match (gettype($value)) {
            
'integer' => 'integer',
            
'double' => 'number',
            
'boolean' => 'boolean',
            
'NULL' => 'null',
            default => 
'string',
        }];
    }

    return [
        
'type' => 'object',
        
'properties' => (object) array_map(lang_translation_schema(...), $value),
        
'required' => array_map(strval(...), array_keys($value)),
        
'additionalProperties' => false,
    ];
}

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.