views:

43

answers:

1

Hello,

I am not sure if the is a duplicate post. But I have a plugin (js + forms + html + php) which can be added to various sites. These sites may have different encoding say ISO-8859-1,ISO-8859-9, utf8 etc. I cannot control their encoding of the html or anything.

I am wondering what is the best way to make my php + js + html + forms + mysql support internationalization. Can my forms accept diffent encoding even if the page has a different encoding?

What are the best ways to do internationalization at these levels: 1. PHP 2. JS + HTML + FORMS 3. MYSQL

Thank you for your time.

+1  A: 

Internationalization is a seemingly simple, yet very complex feature to implement. If you have a tightly coupled architecture, it will be a royal pain to implement this beast.

A lot of internationalization will be handled on the back-end with your database - assuming that you are focusing on a data driven website. If this is the case, it will likely just lead to a few changes to your table structure and the queries performed on that data.

For example, let's say your website has to display a welcome message. You'd push this to the back-end into a table that can resemble something like so:

 MessageTable
    :id
    :message
    :lang_code

Where lang_code is calculated from your browser. So you could have records that appear like this:

MessageTable
1     Hello There     en-us
2     Hola            es-sp
3     مرحبا           ar-sa

and you would make the language code part of your sql query. Granted you could normalize this out to a greater extent, but I think you might get the idea.

In terms of encoding, I can't really speak much as I'm not entirely up to speed on it. In terms of form submissions, I don't believe it should really matter much, it's just how you handle the strings. You'd probably have to do some extra processing by looking at the encoding and deciding how to manipulate the strings, although they might be unicode.

MunkiPhD