0

I am trying to create a multilingual website

I may be going about this the wrong way but here it goes

So just to test first in index.php i have:

<?php
$CURRENT_LANG = "en";
require'./includes/essentials/config.php';

include_once'./includes/essentials/header.php';
include_once'./includes/plugins/search-bars/global-nav.php';
include_once'./includes/essentials/footer.php';

php echo $test 
?>

in my config.php i have:

<?php
if($CURRENT_LANG == "en"){
    include_once $_SERVER['DOCUMENT_ROOT'].'/gps/includes/language/lang-en.php';
}else{
    if($CURRENT_LANG == "pt"){
        include_once $_SERVER['DOCUMENT_ROOT'].'/gps/includes/language/lang-en.php';
    }
}
?>

in lang-en.php i have:

<?php
$test = "Hi";
?>

in lang-pt.php i have:

<?php
$test = "Olá";
?>

The question at hand is how would i make it so that the user can change the var from en to pt so i can have to php files with all the translations needed?

Or is this a really bad way to implement multiple languages?

0 Answers0