Friday, May 1, 2009

Easy Multi-Language for your website

Hi Friends & Techies,
I came after a long back time with more tips & i'll share you more frequently in coming months. Now in the post i'll start sharing about how to create Multi-language website using php.

First we must plan for the multilingual website
1) Every time when we add new language it should support the website without anymore alteration in the Web pages
2) Must have unique variable for each & every page for the content [so there wont be redeclaring].
3) For more user friendly use more text and design your pages with css. Avoid using images [Until you need it].
4) After designing your template, put all the contents in main language. Make it aligned and look out for browser compatibility
5) Going for Multi-language option
6) Create a file called "defines.php"
7) In the defines.php you define language for file
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];//Detecting Default Browser language
else {
$lang = $_COOKIE['language'];//Detecting if cookie was set
case "en":
require("lang/english.php"); // where the content in english is stored
case "cn":
require("lang/chinese.php"); // where the content in chinese is stored
case "zh-CN":
case "zh-cn":
8) Include the above file in all the webpages in your website


9) In all the webpages you must change/add the meta tag information
<1meta http-equiv="content-type" content="text/html; charset=UTF-8"> //Remove 1 in the meta tag

10) for creating a new language you must save the file in UTF-8 format.
Follow the steps to save it in UTF-8
a. Open the notepad (start->run->type "notepad")
b. Save the file as "chinese.php".
c. In the save option Enter file name as "chinese.php" , Save as Type as "All Files", In encoding as "UTF-8" ;
11) Now with as usual PHP Syntax create some unique variable.
12) For chinese translation Go to Google Translation.
13) Copy the translated text and paste it in notepad for a particular variable.
14) Create a webpage, include the defines.php file, print the variable defined in chinese.php file

For Demo: Multilingual Website

Thats it, you've created multilingual website. If you've any doubt, just comment to this post i'll reply as soon as possible.


Anonymous said...

I am new to to php

Can I see a example of what this will be in step 11?
PHP Syntax create some unique variable.


Sathish Kumar said...

Unique variable means if you're using $country = "India" means you should not use declare another variable $country = "Pakistan" you can use $country = "India" in english language $country = "some french word" in french.php.

Никола said...

Hi Your Guide isn`t Correct.
I can`t Understand Deffline are you using or what, can You make new guide with full steps what exacly to do please

Damir said...

How to change language without load page? (where is the ajax script for this?)


Vijaya Kumar S said...

See this link for multi language website,

raj said...

do i need to set alphabet or my paragraphs from english site to arabic? How variables are set for this? Please illustrate with example. Thanks in advance.

Sathish Kumar said...

Hi Raj,
You don't need to set alphabets.
You need to assign respective words from english to Arabic.

For Example:
let we choose english word: How are you?

These word should be translated to French

In english.php
$text = "How are you";

In french.php
$text = "Comment êtes-vous?";

In index.php
after detecting particular language
echo $text;

AikoChu said...

hi, I am totally new to php, so could u plz teach me how to write the code in the button side? (when I need to click the "eng" or "chinese" button, how can it to be detected and transform to other page?)

Amit Sinha said...

I have created language file to create multiple language site in php but it only changes static content how can i change dynamic content please give me any idea.

Amit Sinha said...

I have created language file in php to make multiple language site but i don't know how to change language after selecting the language from drop down and how to change dynamic value, please advice me how can i change dynamic value in multiple language in php, it's very urgent.

Sathish said...

Hi Amit,
If you want to make it dynamic then you need to use translator service from google or you need to store the text in different languages in the database.

Anonymous said...

I am creating site with multilanguage. I have converted the static content with variables. But what about the dynamic content that is coming from tables. What must be done for that content. should i make other tables or fields in existing tables.


Anonymous said...


Actually I am new to Php (I have no Idea about this language). I created my simple website in html and css.. So when I do have 6 web-pages( nav links), where do I keep those files?? You said ,we need to create a polish.php file but How do I distinguish all my web pages in this one file??
please help
Thank you,


Pirata said...
This comment has been removed by the author.
Pirata said...

There's miss a function in the href when we click on the flag. For example:

i have an index.php that have:

include ("defines.php");

a href="" img src="languages/en.png" width="16" height="16" /a

where en.png is the english flag.

What i have to write on href to change the language to english. (original language is portuguese)

Sathish said...

You can pass the index.php?lang=en
after the page reloads then you've to set the cookie & reload the index.php file again.

after setting the cookie

karnti said...

hai I am Web Site Developer Cum Seo Programmer.

I Do Not Understand in J query Library and java script.

Mihai said...

I've also tried to make an tutorial base on the same subject, it's a multi-language php class using xml files which support utf-8

Multilingual web sites said...

A multi-language website is a website that provides its visitors with content in two or more languages.

Multilingual web sites

Maryam Mirmoloukan said...

thanks for your post :)
but how about data in database ???
how should they translate???

Greg David said...

Hi everyone! If you are involved in localization projects, I suggest trying to easily translate your website in multiple languages. It a software localization tool that has a simple interface, plenty of useful features and can simplify the localization workflow.

Hiren Makwana said...

Hi everyone! this is solution for static data , i want to convert all dynamic data in to multi-language

anyone can suggest other way

Naviya Nair said...

Great Article..
PHP Training in Chennai
Online PHP Training
Online PHP Training India
PHP Training Chennai
PHP Training institute in Chennai

Ramya k said...

Thanks for sharing this information.It was very nice blog to learn about PHP

cc said...


Bhavya Kumar said...

My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai

Tina Kenard said...

Great and impressive article!! Got to learn and know more about web development. To know more refer create website for much more unique ideas.
PHP Training Institute in Chennai|PHP Training in Chennai

Amirtha rao said...

Thanks for sharing your informative article. As every business owner desire to be the part of digital marketing, there is massive demand for attractive and responsive website. It automatically increases the career prospects of web design and development professionals. Taking Web designing course in Chennai will help students to enter web design industry with good salary package.

JamesWilliam said...

Interesting post! This is really helpful for me. I like it! Thanks for sharing!
Mobile application developers in Chennai | PHP developers Chennai

CIIT Noida said...

CIITN is the best SAP training and placement Institute in noida. Contestant will analyze in keeping with modern-day enterprise trends by way of certified and industry experts & SAP training Institute in Noida. They provide a 100% placement help with the best training of IT cousrses.

If you are looking best sap training in Noida then you can join CIITN. One of the premier training and development institute for SAP Training Program in Noida. The company provides 6 weeks/ 6 Months Training for SAP. They provide training in all SAP Modules like SAP HANA,SAP B1, SAP FICO etc. Just come for free demo class and then join SAP and move up in your career .

SAP Training Institute in Noida
sap training in noida
sap institute in noida
sap course in noida
best sap training institute in noida

Careen joseph said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

Inigo joseph said...

Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

Java Training Institute Bangalore

kevingeorge said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

Java Training Institute Bangalore

Best Java Training Institute Chennai

tansitanu said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
Hadoop Training Institute In chennai

john kevin said...

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

Amazon Web Services Training in Chennai

Best Java Training Institute Chennai

Riya karakoti said...

Webtrackker Technology is offering Digital marketing course in noida Webtrackker for all learners and students. Here Students are access all types of services for quality results.

Best Web Design Training Institutes in Noida

Salesforce Training institute in noida

Hadoop Training in Noida

Digital Marketing Training Institute in Noida

Jack Adok said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me.

Best Cartoon Picture Apps
Best Alternative of TrueCaller

Sunil Dubey said...

Best Sap fico Training Institute in Noida sector 15
Best Sap basis Training Institute in Noida sector 15
Best Sap hr Training Institute in Noida sector 15
Best SEO training institute in noida Sector 15

Best Php Training Institute in Noida Sector 16
Best Java Training Institute in Noida Sector 16
Best Hadoop Training Institute in Noida Sector 16
Best node js Training Institute in Noida Sector 16
Best openstack Training Institute in Noida sector 16
Best linux Training Institute in Noida Sector 16

Riya karakoti said...

Best Salesforce Training Institutes in Noida Webtrackker Technology a noticeable educational portal has carved a niche for itself in the field of academy services and offers the salesforce Training in noida to the students.

Java Training Institute in Noida

Best Web Design Training Institutes in Noida

Salesforce Training institute in noida

Hadoop Training in Noida

rohit pal said...

Hello friends, my name is Rohit and I work as the head of digital marketing in Delhi. I am affiliated with many MNC’s Software developers. If you are talking about the best educational institution in Delhi,Webtrackker help me get the best educational institute in Delhi.we are you offering some best services in our institute.with 100% job offers are available .

Webtrackker is one only IT company who will provide you best class training with real time working on marketing from last 4 to 8 Years Experience Employee. We make you like a strong technically sound employee with our best class training.

C - 67, sector- 63, Noida, India.
F -1 Sector 3 (Near Sector 16 metro station) Noida, India.
+91 - 8802820025

more information

Best SAS Training Institute in delhi

SAS Training in Delhi

SAS Training center in Delhi

Best Sap Training Institute in delhi

Best Sap Training center in delhi

Sap Training in delhi

Best Software Testing Training Institute in delhi

Software Testing Training in delhi

Software Testing Training center in delhi

Best Salesforce Training Institute in delhi

Salesforce Training in delhi

Salesforce Training center in delhi

Best Python Training Institute in delhi

Python Training in delhi

Best Python Training center in delhi

Best Android Training Institute In delhi

Android Training In delhi

best Android Training center In delhi

Prasanth Krishnan said...

Nice Blog, Thanks for sharing this valuable one.This is very useful for me and gain more information,

Web Designing Training in Chennai