Dec 29, 2008 - Uncategorized    43 Comments

PHP & MySQL: Creating a website in your local language smoothly

Hello Developer,

You know English is the international language and accepted as international communication. So, most of the websites have been developed in English. But in many other times, a developer needs to work with local languages where they are developing a website in PHP. If you develop in local language, you need to know a small trick and that will show your content properly in all browsers smoothly.

So, what is the technique?

Well. Let me explain step by step.

Step One: An observation
I will show you the source code of two Bengali newspaper. In this newspaper:, the fonts and text comes properly in all browsers. But in this newspaper:, it can show text and fonts properly only in Internet Explorer.

Now the matter is we must make sure our content will be displayed properly in any browser. Right?

OK. So what is the difference between the two websites I just gave example?

If you take a look at the source code of the first website’s content, you will find it is like this:সઃপাদক

This is another website that had been developed as smooth site in the same technique: If you check its code, you will see that it uses same type of code for its text.

So, what are these পাদকীয় things? It is very interesting that these are universal representation of local language in HTML entities. For every character of any local language, there is a unique and fixed symbol defined such as প in HTML entities. When you bring this kind of text in your browser source code, the site content looks smooth without any break and fonts displays properly.

Now if you open the source code of, you will see something like AvR beg RvZxq msm` wbe©vP‡b jovB n‡e †RvU-gnv‡Rv‡Ui g‡a¨. The matter is they are also showing Bengali news content, but in a different way that is not useful in cross-broswer platform. This is often totally recognized by only Internet Explorer and often partially recognized by other browsers.

Step Two: Storing your local language content in the database
You see I have some content in my local language (Bangla) in the database.

Step Three: Converting your local language text in Universal code
Well. This is extremely easy.

The displayLocalContent() function is going to display the news and convertToLocalHtml() function converts my utf-8 content to HTML entities.

And here in index.php I am executing my displayLocalContent() function.

As a result, the output is now as ঢাকা, ডিসে etc.

Step Four: You need to check my other posting for SELECT, INSERT & UPDATE your local language.
Here goes my other article so that you can perform all required operations for storing and displaying information in browser smoothly:

An alternative way
I have an alternative way in my mind and that is when you store the data in the database, you can first convert them to universal code such as কীয়and then directly show your text.

This article will cover any language such as Afrikaans, Albanian, Amharic, Arabic, Armenian, Assamese, Aymara, Azeri, Belarusian, Bengali, Bislama, Bosnian, Bulgarian, Burmese, Catalan, Chinese, Mandarin,Croatian, Czech, Danish, Dari, Dhivehi, Dutch, Dzongkha, English, Esperanto, Estonian, Fijian, Filipino, Finnish, French, Frisian,  Gagauz, Georgian, German, Greek, Guaraní, Gujarati, Haitian Creole, Hebrew, Hindi, Hiri Motu, Hungarian, Icelandic, Indonesian, Italian, Japanese, Kannada, Kashmiri, Kazakh, Khmer, Korean, Kurdish, Kyrgyz, Lao, Latvian, Lithuanian, Luxembourgish, Macedonian, Malagasy, Malay, Malayalam, Maltese, Māori, Marathi, Mayan, Moldovan, Mongolian, Montenegrin,Náhuatl, Ndebele, Nepali, New Zealand Sign Language, Northern Sotho, Norwegian, Oriya, Papiamento, Pashto, Persian, Polish, Portuguese, Punjabi, Quechua, Romanian, Rhaeto-Romansh, Russian, Sanskrit, Serbian, Shona, Sindhi, Sinhala, Slovak, Slovene, Somali, Sotho, Spanish, Swahili, Swati, Swedish, Tagalog, Tajik, Tamil, Telugu, Tetum, Thai, Tok Pisin, Tsonga, Tswana, Turkish, Turkmen, Ukrainian, Urdu, Uzbek, Venda, Vietnamese, Welsh, Xhosa, Yiddish, Zulu etc.

You can also download this small piece of code from here:

Thank you for reading.


  • As far as learning another language is concerned, can I put in a word for Esperanto?

    During a short period of 121 years Esperanto is now placed within the top 100 languages, out of 6,000 worldwide, according to the CIA factbook. It is the 17th most used language in Wikipedia, and in use by Skype, Firefox and Facebook.

    Native Esperanto speakers, include George Soros, Nobel Laureate Daniel Bovet, Ulrich Brandenberg, the new German Ambassador to NATO, and World Champion Chess Player, Susan Polger.

    Further arguments can be seen at and a glimpse of the language can be seen at

  • @ Brian

    Esperanto is added!

  • Nice post .. I will play around with your code tonight to develop my new site.. anyway thanks for this post this is really helpful

  • how to insert telugu font in database…..can u please answer me

  • @ swathi

    there is no need to insert Telegu font in the database.

    if you make your site in UTF-8:

    (i) if the user has Telegu font, she can see your site properly

    (ii) if the user does not have Telegu font installed in her PC, keep a font download page and give a link to download the font and how to install the font. next, request the user to refresh the page after the font is installed

  • Hi,
    Well, now I am able to retrive the characters from mysql stored in hindi/Urdu. So one part is solved. Another part is that the browser sourse page still display the Universal code and not the hindi/Urdu. I’d like that the browser sourse page should also display local language and not the Universal codes. Like your example: ঢাকা, ডিসে on this page.

  • @ S.G. Hussain

    If you want so, you need to convert your UNICODE back to local language.

    I think PHP has built-in function for this.

  • Hi there,
    I’m sorry to enumerate the problem in such a detail. It was something to do with connect function and defining language there itself. I tried. It works now.

  • @ S.G. Hussain

    That is what I meant for you to do.

    And happy to know that your problem is solved.

  • Thank you this helped me a lot.

  • i have arabic text already iserted into the database.

    now,i want to convert it into the english,i have already made the script for translation.But have prblm with it.

    whent i translate the text into english it shows strang characters when printed and database is remained empty when inserted this text into it.
    if u can hepl me i’ll give u more detaill.

  • can help me in storing the Tamil font in phpMySQL.

    When i copy a tamil text from the browser it is displaying, but when i type in the MSword and copy them to store in MySQL TABLE. It is showing only the keyboard english characters.
    So plz guide me sir and mail the answer to my ID

  • your website very nice……….

  • can u tell me ,how to show a video in our web site?

  • @ ashiq

    use wordpress plugin or embedded code.

  • I can not see font in my website.
    Please send me language of PHP for input the font in my website.
    I write contents in sutonnyMj font.
    I have seen source code of,
    all are using Bangla_css.php
    But I can not find it how to create and how is functioning properly

  • nice.. keep it up

  • @Admin : hi sir, this is looking good…i m getting the output from db wat i want as telugu script…. how can i insert data into db in telugu font? plz do needful..


  • @Admin : when i m trying to insert data into DB , it takes as different formate. wat i need to do? plz explain me clearly….

  • i have a table named search in that i have keywords,here i want to crawl the results from the web for these keywords i did this fine for english now i want to crawl the results for slovak language i mean for slovak keywords
    i put the collation for table and database ” utf8_unicode_ci ” but it not worked properly it shows the warning message like “mysql_query() expects parameter 2 to be resource, null given”
    can u please help me.

  • Respected Sir,

    I want to convert a whole English Website to Gujarati when user clicks on Gujarati & vice versa… The Website is Dynamic & the data is to be entered by Admin…, Can You help me in this? Plz let me know how this can be done? How data daily typed from Admin Panel in English can be converted in Gujarati by just 1 click & vice versa??

  • Thank you for the post! Learning a new language and learning HTML are difficult enough alone, but putting the two together is quite a challenge!

  • Can u help me to submit bangla data using ajax into mysql table?

    if i submit it stored as

  • @ Bashar

    try to use jQuery post method.

    i am working in a big bangla project where I am using Ajax now and then with the help of jQuery get & post methods.

  • Hi,

    I am creating a website in telugu using PHP, MySQL. I need to display the telugu in eenadu font. I have to type telugu in MS-Word or Notepad and have to copy n paste in Admin section. My need is all text will be displayed in Admin section as well as in front end in eenadu font i.e. in Telugu. Can you tell me how can I do this using PHP, MySQL?

  • @ swagata

    You need to embed fonts. Nowadays there are scripts that helps to show custom fonts as it it. I used something in Javascript such as for wordpress I used “wp-cufon” plugin.

  • I need clear and easy way of inserting telugu font into a webpage so that the website can accessible in any PC/computer without telugu software being installed so far. Give me idea/suggestion about uploading local language font into the database.. Please..

  • i m using ckeditor with marathi hindi lan and was getting problem.
    Your Below line worked for me !
    Many thanks !

    Thanks Admin !

    $localHtmlEquivalent = mb_convert_encoding($localHtmlEquivalent,”HTML-ENTITIES”,”UTF-8″);

  • when I using this, I got the message that error that is Fatal error: Call to undefined function mb_language() in ../class.unicode.php on line. that line is mb_language(‘uni’); what is the real problem.

  • Hi, Could you please tell me if we can translate the language form english to nepali using php and mysql. I am doing this project and my client wants both in english and nepali.

  • Thanks

    I need to write below line every time when I call mysql query through PHP.

    mysql_query(“SET character_set_results=utf8”, $this->dbLink);

  • Thank you very much

    I need to write below line every time when I call mysql query through PHP.

    mysql_query(“SET character_set_results=utf8”, $this->dbLink);

  • Hello!
    your website is so pretty and pretty useful too! Thanks a ton.
    I have a question regarding the below –
    I have an alternative way in my mind and that is when you store the data in the database, you can first convert them to universal code such as কীয়and then directly show your text.
    currently my table has unicode values only, and i’m trying to compare/analyze it against the form field (input type text) .
    So …how do you “first convert them to universal code” in php?
    Please advise. Thanks in advance!

  • @ Poongothai

    There is a PHP function for this. I used the function long ago. But now I cannot remember the name of the function.

  • Thanks for the quick response.
    hmm, I think you are talking about utf_encode… it did not work for me . But I would have messed up somewhere- for this is the first and hopefully last php page that I code. I just tried mb_strtoupper into another variable, and it is working as expected. I know it is silly, but why question something which is working – so I let it be. 🙂

  • I am trying to launch odia (oriya) news website and I have installed wordpress and for content write in oriya using INDIC IME plugin. My problem is in windows 7 it is showing something and windows xp the oriya letter letters are different. As you have mentioned I tried that class but still not able to see same letters in both the system.

    the other problem is in windows xp system if font is not installed it is displayed box box…

    I hope you will help me out.

    Thanks in advance



  • Nice stuff, I get helpfull..

    Thanks a lot…

  • Can you Help me For making web site in
    with php my sql

  • Great job
    I run am Malayalam site in wp

  • Thanks….a lot
    your article helped me so much.

  • Thanks for this article, your instructions helped me to work with my language text (Kurdish).

  • i’m new at web development and want to develop site in “marathi” i am using macromedia dreamweaver i am facing problem ” Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\wamp\www\class.unicode.php on line 46″ plz reply.

Got anything to say? Go ahead and leave a comment!