views:

227

answers:

5

I was asked by an interviewer today how I would implement Arabic as a second language into a PHP web application. I talked about choosing a unicode encoding for the database and the front-end, and designing RTL friendly user interface modules. And he didn't seem too happy with the answer. I don't really know anything about multi-lingual systems, how would you have answered that question?

A: 

Use UTF-8 for all:

php File format -> UTF-8.

MySQL database -> UTF-8 Unicode.

Amirouche Douda
+1  A: 

very important thing is to make robust language manager for flexible loading of language-specific strings and settings. In PHP you have to be careful even with UTF-8 file format, because current PHP versions doesn't have complete unicode support. Here you can read more about what's happening with unicode support:

http://schlueters.de/blog/archives/128-Future-of-PHP-6.html

You have also many more problems to deal with: localized formatting, sorting - collation, multi-currency and multi-timezone logic.

praksant
+3  A: 
  1. Ensure you are using UTF-8 encoding on the site. Even that isn't foolproof as prakscant mentioned.
  2. Strings - You would need to be disciplined in localizing every string and phrase that could appear to the user. That means error messages, status bar messages, alert boxes, dialog boxes etc. You might create a string map or directory listing which lets you find strings by key (which could be in English).
  3. Localized images - If you use images for buttons (that contain text), those too would need to be localized. You might create an image map or directory file that lets you find images for the appropriate culture by some key.
  4. Layout - Since Arabic is right-to-left, you would likely need to have separate CSS files to properly handle the site appearance so that the text read and displayed correctly. For example, you might want sidebars on the right side of the screen instead of the left.
  5. Date formats - You would need to format dates based on the culture code and ensure that filters based on dates were properly interpreted.
  6. Database collation - You would need to ensure that the database stored data in UTF-8 or Unicode format. You would also need to be careful about any filters inside of queries which searched on strings unless those strings are system values that are unviewable and unchangable by an Arabic user.
Thomas
A: 

Not sure why they wouldn't be happy with your answer. UTF-8 for all text - strings/database, etc. Separate CSS (to set the rtl text property) Other thing to take into consideration... images are also rtl. So if you currently use images for a navbar, etc., you have to realize that they will load rtl.
Other than that, Arabic is just another language like anything else, the only difference is that it's bi-directional.

NinjaCat