What are some common methods for translating values in PHP without modifying external libraries?

When translating values in PHP without modifying external libraries, common methods include using arrays or switch statements to map values to their corresponding translations. This allows for easy maintenance and customization of translations within the codebase.

// Using arrays to translate values
$translations = [
    'hello' => 'Bonjour',
    'goodbye' => 'Au revoir',
];

$value = 'hello';
if (isset($translations[$value])) {
    echo $translations[$value];
}

// Using switch statements to translate values
$value = 'goodbye';
switch ($value) {
    case 'hello':
        echo 'Bonjour';
        break;
    case 'goodbye':
        echo 'Au revoir';
        break;
}