Multi-Language Support in MYSQL

This article is about how to store and manipulate multi languages in mysql table. May be useful while developing globalization / locale support enabled websites

By default mysql supports many european languages, Since unicode character(UTF-8) support implemented in mysql it allows us to store many of the indian (Asian) languages.

Mysql supports Gujrathi, Hindi, Telugu and TAMIL among too many languages in the subcondinent
Let’s consider TAMIL language and workout:-

To store & search tamil character sets in MySQL table, first of all we need to create a table with character set UTF-8.

CREATE TABLE multi_language
(
id INTEGER NOT NULL AUTO_INCREMENT,
language VARCHAR(30),
characters TEXT,
PRIMARY KEY(id)
) ENGINE=INNODB CHARACTER SET = utf8;

INSERT INTO multi_language VALUES (NULL, ‘English’, ‘abcdefghijklmnopqsrtuvwxyz’);
INSERT INTO multi_language VALUES (NULL, ‘Arabic’, ‘ﺃ‎ﺏﺝﺩ‎ﻫﻭﺯﺡﻁﻱﻙﻝ‎ﻡﻥ’);
INSERT INTO multi_language VALUES (NULL, ‘Arabic’, ‘ﺃ‎ﺏﺝﺩ‎ﻫﻭﺯﺡﻁﻱﻙﻝ‎ﻡ ﻥ’);
INSERT INTO multi_language VALUES (NULL, ‘Hindi’, ‘ਓਊਨਣਥਨਫ’);
INSERT INTO multi_language VALUES (NULL, ‘Thai’, ‘ЁώύЂЬЫЗЪШДГЦШГЕ’);

INSERT INTO multi_language VALUES (NULL, ‘Telugu’, ‘ని మీ హొమ్ పేజిగా అమర్చుకోండి’);
INSERT INTO multi_language VALUES (NULL, ‘Tamil’, ‘இந்தியா நாட்டின் பக்கங்கள்’);
INSERT INTO multi_language VALUES (NULL, ‘Arabic’, ‘البحث في الصفحات العربية ‘);
INSERT INTO multi_language VALUES (NULL, ‘Korean’, ‘시작페이지로 하세요 채용정보 광고 프로그램 정보’);

Command to Change the client character set (which sends request to the server):

this has to be done so that the server can understand the request which send by Client.

— To be executed at Client Side
 SET NAMES ‘utf8’;

— System Variable Name : character_set_client

— To Set Locale time zone name
SET @@lc_time_names = ‘en_US’;

For Tamil language, we need to set the time zone as follows..

SET @@lc_time_names = ‘ta_IN’;

Now, we use select query and check out the result.
Important :
————–

 1. If the result shows like the ???? then prpoerly in your system (windows XP) need to install the  extral language support tool by enabling the following options,

 Control Panel -> Regional and Language Option ->  Languages -> Install files for complex script and right-to-left languages (including Thai) 

 2. While fecthing the row using PHP, for displaying the Multilanguage content properly, you must need to include the Meta tag like,

 <META HTTP-EQUIV=”Content-Type” CONTENT=”text/html; charset=utf-8″>
 if needed the add mysql_query(‘SET character_set_results=utf8’) in the php code before fecthing the reocrd.

15 Comments

  1. saran said,

    July 28, 2009 at 1:56 pm

    hi, i want to convert the string into regional language using php.. do u have any ideas?

  2. Rose said,

    August 24, 2009 at 12:13 pm

    how to retrieve tamil language from php mysql database

    • rafeekphp said,

      August 25, 2009 at 5:40 am

      Hi Rose,
      You can see my post in the MYSQL section, you will get idea how to get/store the TAMIL language to MYSQL.

      Thanks
      Rafeek 🙂

  3. rosee said,

    August 26, 2009 at 12:43 pm

    How do you typed this “இந்தியா நாட்டின் பக்கங்கள்” in DreamWeaver to insert in PHPMySQL.
    Any one can help me in storing the Tamil font in phpMySQL.
    I copied a tamil text from the browser and tried to store in database it s working, but when i type tamil 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

    • rafeekphp said,

      August 27, 2009 at 4:29 am

      Hi rosee,
      You can use Google Langauage builder to type the tamil language in the browser and on submit just use the blog post instruction to insert the TAMIL typed content in MYSQL same as TAMIL format.

      Thanks
      Rafeek 🙂

      • rose said,

        August 27, 2009 at 4:56 am

        Hi Rafeek,
        Thanks for your reply. Am doing Tamil online test software using PHP/MySQL.. I need to insert 50 question papers each contains 50 to 100 questions in tamil including answers. I need to know more about the google language builder, whether it is free or cost..

  4. September 21, 2009 at 9:32 am

    Hi all,
    I guess below link may useful for someone. Try this link. http://www.vijayakumar.org/index.php/2009/08/easy-multilangual-english-tamil-website-creation-using-php/

  5. swetha said,

    September 23, 2009 at 8:17 am

    hi
    how to store telugu information in mysql databaseand how to take the same data which is in telugu on browser.

  6. nandhini said,

    October 5, 2009 at 9:47 pm

    thanks a million!

  7. October 20, 2009 at 2:10 pm

    Creating a database in telugu – create database teugu -character set utf8;
    creating a table -with contents in telugu –
    create table tel(raga varchar(20) character set utf8,
    tala varchar(18) charater set utf8,
    kirtana varchar(20) character set utf8
    ); = Is there any mistake in this statement= I use Fedora9 MySQL 5.1.32
    Yes, there is support for utf8; Thanks in advance
    G.BSUBRAHMANYAM 20.10.09

  8. kishore said,

    February 23, 2010 at 5:40 am

    hi, when i am trying to insert telugu script from my webpage to database, the font is corrupted. but when i execute directly into mysql table, than i am getting correct font. here my problem is when i trying to insert telugu script, it should be saved in db as same telugu font.can any body help me plz.

  9. ranjith said,

    May 4, 2010 at 10:44 am

    While i creating sql database i do not support for UTF-8 Character set .
    How can i store Tamil letters in sql database..
    Plz reply

    • rafeekphp said,

      January 7, 2011 at 10:43 am

      Hi Ranjith,

      You need to install the UTF-8 font in you system in order to get the TAMIL fonts.

      Thanks

  10. deepika55143 said,

    June 9, 2011 at 6:21 am

    hey ur guides to retrieve tamil data from database is really helpful. i solved mine with ur post.!!!!!!

    thanks!


Leave a comment