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.

65 comments:

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

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

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

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

    thank's

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

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

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

    ReplyDelete
  8. 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?)

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

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

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

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

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

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. 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)

    ReplyDelete
  16. @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");

    ReplyDelete
  17. hai I am Web Site Developer Cum Seo Programmer.

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

    ReplyDelete
  18. 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/

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

    Multilingual web sites

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

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

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

    anyone can suggest other way

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

    ReplyDelete
  24. ASdxscfszvdvfdsfvzsfvzsczcvzxcz

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

    ReplyDelete

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

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

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

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

    Best Cartoon Picture Apps
    Best Alternative of TrueCaller

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

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

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

    Web Designing Training in Chennai

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

    ReplyDelete
  53. Nice tips for coding practice.This Python online practice course supports learning by doing.

    ReplyDelete
  54. "Unlock your data analysis potential with the best best power bi coursedesigned for beginners and professionals alike. Learn to create insightful dashboards and make data-driven decisions confidently."

    ReplyDelete
  55. EasyPayTax is a tax and business compliance service that helps individuals and businesses manage tax registrations, filings, and regulatory requirements. It simplifies processes like TAN registration, PF/ESI payments, and other statutory filings, making tax compliance easier and more efficient
    GST registration in Hyderabad

    ReplyDelete