PHP Multi languageSupport To Website Management

PHP Multi languageSupport To Website Management

Today, We want to share with you PHP Multi language Support To Website Management.
In this post we will show you Add Multi-language Support to a PHP Website, hear for Multi-language Support to Website using PHP we will give you demo and example for implement.
In this post, we will learn about php – Multi-language website management with an example.

in this example i will show you 3 languages session to dispaly chnage languages

3 Language Example :

Folder structure:

create a folder pakainfo

pakainfo
-#index.php
-#common.php
-#languages
–#lang.en.php
–#lang.de.php
–#lang.es.php
-#images
–#de.png
–#en.png
–#es.png

lang.en.php

<?php
/* 
------------------
Language: English
------------------
*/
$lang = array();
$lang['PAGE_MAIN_TITLE'] = 'www.Pakainfo.com';
$lang['MAIN_HEADER_TITLE'] = 'Happy to Help You.!!!!';
$lang['IMP_SITE_NAME'] = 'pakainfo';
$lang['MAIN_SLOGAN'] = 'All USERS ALWAYS WELCOME!!!';
$lang['PAGE_HEADING'] = 'FREE LEARN TO ANGULARJS';
// Simple Top Menu Display
$lang['MENU_HOME_PAGE'] = 'Home';
$lang['MENU_ABOUT_US_PAGE'] = 'About Us';
$lang['MENU_OUR_PRODUCTS_PAGE'] = 'Our products';
$lang['MENU_CONTACT_US_PAGE'] = 'Contact Us';
$lang['MENU_ADVERTISE_PAGE'] = 'Advertise';
$lang['MENU_SITE_MAP_PAGE'] = 'Site Map';

$lang['PAGE_CONTENT_INFO'] = 'Many Many Thanks a lot For Visiting my site.';

?>

lang.es.php

<?php
/* 
------------------
Language: Spanish
------------------
*/
$lang = array();
$lang['PAGE_MAIN_TITLE'] = 'www.Pakainfo.com (Www.Pakainfo.com)';
$lang['MAIN_HEADER_TITLE'] = 'Feliz de ayudarle !!!!';
$lang['IMP_SITE_NAME'] = 'pakainfo';
$lang['MAIN_SLOGAN'] = 'Todos los usuarios SIEMPRE BIENVENIDOS !!!';
$lang['PAGE_HEADING'] = 'GRATIS APRENDE A ANGULARJS';
// Simple Top Menu Display
$lang['MENU_HOME_PAGE'] = 'Home';
$lang['MENU_ABOUT_US_PAGE'] = 'About Us';
$lang['MENU_OUR_PRODUCTS_PAGE'] = 'Our products';
$lang['MENU_CONTACT_US_PAGE'] = 'Contact Us';
$lang['MENU_ADVERTISE_PAGE'] = 'Advertise';
$lang['MENU_SITE_MAP_PAGE'] = 'Site Map';

$lang['PAGE_CONTENT_INFO'] = 'Many Many Thanks a lot For Visiting my site.';

?>

lang.de.php

<?php
/* 
------------------
Language: German
------------------
*/
$lang = array();
$lang['PAGE_MAIN_TITLE'] = 'www.Pakainfo.com';
$lang['MAIN_HEADER_TITLE'] = 'ohpahhay to help you.!!!!';
$lang['IMP_SITE_NAME'] = '4freeng';
$lang['MAIN_SLOGAN'] = 'sweet welcome to you!!!';
$lang['PAGE_HEADING'] = 'FREE LEARN TO ANGULARJS';
// Simple Top Menu Display
$lang['MENU_HOME_PAGE'] = 'Home';
$lang['MENU_ABOUT_US_PAGE'] = 'About Us';
$lang['MENU_OUR_PRODUCTS_PAGE'] = 'Our products';
$lang['MENU_CONTACT_US_PAGE'] = 'Contact Us';
$lang['MENU_ADVERTISE_PAGE'] = 'Advertise';
$lang['MENU_SITE_MAP_PAGE'] = 'Site Map';

$lang['PAGE_CONTENT_INFO'] = 'Many Many Thanks a lot For Visiting my site.';

?>

common.php

<?php
//Start a session
session_start();
header('Cache-control: private'); //here IE 6 for used to header

if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];

// register new the session and set new the cookie both are set
$_SESSION['lang'] = $lang;

//set cookie here with condition
setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en'; //default english
}
//switch condition here
switch ($lang) {
  case 'en':
  $lang_file = 'lang.en.php';
  break;
  case 'de':
  $lang_file = 'lang.de.php';
  break;
  case 'es':
  $lang_file = 'lang.es.php';
  break;
  default:
  $lang_file = 'lang.en.php';
}
//all lang file to get key words
include_once 'languages/'.$lang_file;
?>

index.php

<?php
include_once 'common.php';
?>
<html><head>
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all">
</head><body>

<div id="formheaderTop"><!-- formheaderTop BEGIN -->

<div id="topheadsection">

<!-- topheadsection BEGIN -->
<div id="all_languages">
<a href="index.php?lang=en"><img src="pakainfo/images/en.png" /></a>
<a href="index.php?lang=de"><img src="pakainfo/images/de.png" /></a>
<a href="index.php?lang=es"><img src="pakainfo/images/es.png" /></a>
</div>

  <div id="webtitle"><?php echo $lang['HEADER_TITLE']; ?></div>
  <div id="websubtitle"><?php echo $lang['SLOGAN']; ?></div>
</div>
<!-- topheadsection END -->

<div id="navtopmenuhere">
<!-- start header section BEGIN -->
  <div class="NAVTOPME">
    <ul>
      <li><a href="#"><?php echo $lang['MENU_HOME_PAGE']; ?></a></li>
      <li><a href="#"><?php echo $lang['MENU_ABOUT_US_PAGE']; ?></a></li>
	  <li><a href="#"><?php echo $lang['MENU_OUR_PRODUCTS_PAGE']; ?></a></li>
      <li><a href="#"><?php echo $lang['MENU_CONTACT_US_PAGE']; ?></a></li>
      <li><a href="#"><?php echo $lang['MENU_ADVERTISE_PAGE']; ?></a></li>	
      <li><a href="#"><?php echo $lang['MENU_SITE_MAP_PAGE']; ?></a></li>
    </ul>
  </div>
</div>
<!-- end header section END -->
<div id="CntSectionDlDiv"><!-- specialdiv start -->
	WELCOME To : <?php echo $lang['PAGE_CONTENT_INFO']; ?>
</div><!-- special div END -->

</div><!-- outerfooter END -->
<div id="ngfooterdemo">
  <p>Copyright © Pakainfo.com </p>
</div>
</body></html>

We hope you get an idea about PHP Multi language Support To Website Management
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Send Email via SMTP Server in Node.js using Nodemailer npm
  2.   VueJS json array object string parse Example
  3.   Linux Crontab Unix Linux Command examples
  4.   Angular 9/8 Material Checkbox Examples
  5.   Laravel 6 Set Timestamps using Eloquent Model
  6.   Enable/Disable debug mode in cakephp
  7.   How to Make a Redirect to page in PHP?
  8.   Paypal Payment Gateway Integration using Java
  9.   whatismyscreenresolution | screen resolution | what is my resolution - Keywords List
  10.   Generate UUID in laravel 5.8 Example