Is it best practice to store gettext variables in a database for easier translation in PHP projects?

Storing gettext variables in a database can provide easier management and translation of text in PHP projects. By storing text in a database, it allows for dynamic updating of translations without needing to modify code. However, it may introduce additional complexity and overhead compared to traditional gettext usage.

// Example code snippet for storing gettext variables in a database

// Connect to the database
$pdo = new PDO('mysql:host=localhost;dbname=translations', 'username', 'password');

// Retrieve the translated text from the database
$stmt = $pdo->prepare('SELECT translation FROM translations WHERE text_key = :key');
$stmt->execute(['key' => 'hello_world']);
$translation = $stmt->fetchColumn();

// Output the translated text
echo $translation;