3 steps to make your website multi-lingual using PHP / mySQL

If you are working on a website which will be supporting multiple languages (i.e. in addition to English) then you should always do the following religiously:

1. Make sure that the charset and collation being used on your mySQL table are utf8 and utf8_general_ci

2. After opening the database connection to mySQL from your web page run the following SQL before running any other query
mysql_query(‘SET NAMES utf8’);

3. Your web page should have the following in the section.
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> (if you are on HTML 4 or less)
or
<meta charset=”utf-8″> (if you are on HTML 5)

Once you do the above you should be able to write and read special characters from other languages like Japanese, Chinese, Russian etc. If you do not make these changes then you may see special characters appear on your web page which would let you know that the language is not being saved properly.

Please note that the above points should resolve any language related issues 90% of the time. If the above do not resolve your problem then it needs to be investigated further to find the real cause.

I hope the above helped you to resolve

Please follow and like us:

Be the first to comment

Leave a Reply

Your email address will not be published.


*