Translate PHP site with strings via require

1

I have a site in PHP and I'm translating it as follows:

<?php 
require_once("includes/translate.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $site_title ?></title>
</head>
<body>
<div id="welcome"><?php echo $div_welcome; ?></div>
</body>
</html>

The require contains the file translate.php :

<?php
$language = $_GET['lang'];
if ($language == "pt") {
insira o código aqui
    $site_title = "Blog do Antonny";
    $div_welcome = "Seja bem-vindo(a) no meu Blog"; 
} 
if ($language == "es") {
    $site_title = "Blog de Antonny";
    $div_welcome = "Bienvenido a mi Blog";
} 
if ($language == "en") {
    $site_title = "Antonny's Blog";
    $div_welcome = "Welcome to my Blog";
}
?>

And in%% all variables are configured with translations for each language. That was the most dynamic way I could think, is there anything that could make this translation more dynamic? Is this an incorrect way to do it?

    
asked by anonymous 07.06.2017 / 23:05

0 answers