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
if($_COOKIE['language']==""){
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];//Detecting Default Browser language
}
else {
$lang = $_COOKIE['language'];//Detecting if cookie was set
}
switch($lang){
case "en":
require("lang/english.php"); // where the content in english is stored
break;
case "cn":
require("lang/chinese.php"); // where the content in chinese is stored
break;
case "zh-CN":
require("lang/chinese.php");
break;
case "zh-cn":
require("lang/chinese.php");
break;
default:
require("lang/english.php");
break;
}
8) Include the above file in all the webpages in your website

include('includes/defines.php');

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.

63 comments:

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.

thanks

Sathish Kumar said...

Hi,
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.

Unknown 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 Grgic said...

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

thank's

Vijaya Kumar S said...

See this link for multi language website,
http://www.vijayakumar.org/easy-multilangual-english-tamil-website-creation-using-php.html

Rajiv 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.
Rajiv

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.

thanks
sachin

Anonymous said...

Hey!!

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,

Justyna

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...

@Pirata:
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
header("location:index.php");

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 http://www.lampcoder.com/create-a-multi-languages-website-using-php-oop-and-xml/

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

Unknown said...

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

Unknown said...

Hi everyone! If you are involved in localization projects, I suggest trying https://poeditor.com/ 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.

Unknown 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

navya said...

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

Unknown said...

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

cc said...

ASdxscfszvdvfdsfvzsfvzsczcvzxcz

Unknown 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

Unknown said...


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

saranya 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

Unknown 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

Unknown said...

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

Best Cartoon Picture Apps
Best Alternative of TrueCaller

Unknown 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

Unknown 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.


WEBTRACKKER TECHNOLOGY (P) LTD.
C - 67, sector- 63, Noida, India.
F -1 Sector 3 (Near Sector 16 metro station) Noida, India.
+91 - 8802820025
0120-433-0760


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

Unknown said...

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

Web Designing Training in Chennai

Unknown said...

Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.

selenium training in chennai
aws training in chennai

nilashri said...

It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

Data Science with Python training in chenni
Data Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in OMR
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore

SRI said...

Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.


rpa training in Chennai | rpa training in velachery

rpa training in tambaram | rpa training in sholinganallur

rpa training in Chennai | rpa training in pune

rpa online training | rpa training in bangalore

Mounika said...

This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
python training in rajajinagar
Python training in btm
Python training in usa
Python training in marathahalli

Unknown said...

A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
java online training | java training in pune

java training in chennai | java training in bangalore

Unknown said...

That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
python online training
python training in OMR
python training institute in chennai

Anonymous said...

Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
Devops Training in Chennai

Unknown said...

This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolite festivity to pity. I appreciated what you ok extremely here.
Data science course in tambaram | Data Science course in anna nagar
Data Science course in chennai | Data science course in Bangalore
Data Science course in marathahalli | Data Science course in btm

Unknown said...

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies

Selenium Training in Bangalore | Best Selenium Training in Bangalore

AWS Training in Bangalore | Amazon Web Services Training in Bangalore

Anonymous said...

Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.

angularjs-Training in velachery

angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

sunshineprofe said...

He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
best safety training in chennai

SANDY said...

Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.

AWS Training in Bangalore | Amazon Web Services Training in bangalore , india

AWS Training in pune | Amazon Web Services Training in Pune, india

uma said...

useful blog


devops course in bangalore

best devops training in bangalore

Devops certification training in bangalore

devops training in bangalore

devops training institute in bangalore

chandana said...

Thanks For Sharing the Wonderful blog...

best android training center in Marathahalli

best android development institute in Marathahalli

android training institutes in Marathahalli

ios training in Marathahalli

android training in Marathahalli

mobile app development training in Marathahalli

sai said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
Python training in bangalore
Python course in pune
Python training in bangalore

sai said...

This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
python training in chennai
python course institute in chennai

sai said...

This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
python training in chennai
python course institute in chennai

jefrin said...

Very good to read thanks for sharing

blue prism training in chennai

gowsalya said...

Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
AWS training in chennai

AWS Training in Bangalore

Unknown said...

Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
Microsoft Azure online training
Selenium online training
Java online training
uipath online training
Python online training


suresh said...

This is Very Useful blog, Thank you to Share this.
DevOps Certification in Chennai

Salesforce Training in Chennai

Microsoft Azure Training in Chennai

Openstack Training in Chennai


Imran said...

Amazing blog
SAP Training in Chennai
SAP ABAP Training in Chennai
SAP Basis Training in Chennai
SAP FICO Training in Chennai
SAP MM Training in Chennai
SAP PM Training in Chennai
SAP PP Training in Chennai
SAP SD Training in Chennai

Training for IT and Software Courses said...

Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.google cloud platform training in bangalore

raju said...

nice blog.......!
inplant training in chennai
inplant training in chennai for it.php
panama web hosting
syria hosting
services hosting
afghanistan shared web hosting
andorra web hosting
belarus web hosting
brunei darussalam hosting
inplant training in chennai

dras said...

very useful post...
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting

subha said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites!share some more.
Ai & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai

Unknown said...

Nice post. I learn something totally new and challenging on websites I stumbleupon every day. It's always useful to read through articles from other authors and practice something from other sites.
Technology

Georgecollege said...

The lab technician course after 12th available at Lab Technician Course After 12th trains students to offer their services as full-fledged lab technologists with the ability of collecting and storing samples; analysing the same and creating reports.

Reshma said...


This post is so interactive and informative.keep update more information...
Software Testing Course in Bangalore
Software Testing Course in Hyderabad

David Fincher said...

This post is so interactive and informative.keep update more information...
hadoop training in velachery
Big data training in chennai