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

lang_translation_append()

Description

Persist validated entries without rewriting any existing translations.

Parameters

ColumnTypeDefaultDescription
$file string Target language file.
$values: array
$values array Validated entries.

Return

void * @throws RuntimeException If the pack could not be read or completely written.

Location

include/lang_translation_functions.php lines 780 to 793

Definition

 
function lang_translation_append(string $file, array $values): void
{
    
$existing = is_file($file) ? file_get_contents($file) : '';
    if (
$existing === false) {
        throw new 
RuntimeException('Could not read language file: ' . $file);
    }
    
$output = $existing === '' || str_ends_with(rtrim($existing), '?>') ? "\n" : "\n";
    foreach (
$values as $key => $value) {
        
$output .= '$lang[' . var_export((string) $key, true) . '] = ' . var_export($value, true) . ";\n";
    }
    if (
file_put_contents($file, $output, FILE_APPEND | LOCK_EX) !== strlen($output)) {
        throw new 
RuntimeException('Could not write language file: ' . $file);
    }
}

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.