. * * ---------------------------------------------------------------------- * * Class Name: Arabic Keyboard Swapping Language * * Filename: ArKeySwap.class.php * * Original Author(s): Khaled Al-Sham'aa * * Purpose: Convert keyboard language programmatically (English - Arabic) * * ---------------------------------------------------------------------- * * Arabic Keyboard Swapping Language * * PHP class to convert keyboard language between English and Arabic * programmatically. This function can be helpful in dual language forms when * users miss change keyboard language while they are entering data. * * If you wrote an Arabic sentence while your keyboard stays in English mode by * mistake, you will get a non-sense English text on your PC screen. In that case * you can use this class to make a kind of magic conversion to swap that odd text * by original Arabic sentence you meant when you type on your keyboard. * * Please note that magic conversion in the opposite direction (if you type English * sentences while your keyboard stays in Arabic mode) is also available in this * class, but it is not reliable as much as previous case because in Arabic keyboard * we have some keys provide a shortcut to type two chars in one click (those keys * include: b, B, G and T). * * Well, we try in this class to come over this issue by suppose that user used * optimum way by using shortcut keys when available instead of assemble chars using * stand alone keys, but if (s)he does not then you may have some typo chars in * converted text. * * Example: * * include('./Arabic.php'); * $obj = new Arabic('ArKeySwap'); * * $str = "Hpf lk hgkhs hglj'vtdkK Hpf hg`dk dldg,k f;gdjil Ygn ,p]hkdm ..."; * * echo "

Before:
$str

"; * * $text = $obj->swap_ea($str);\ * * echo "After:
$text

"; *
* * @category I18N * @package Arabic * @author Khaled Al-Shamaa * @copyright 2006-2010 Khaled Al-Shamaa * * @license LGPL * @link http://www.ar-php.org */ // New in PHP V5.3: Namespaces // namespace I18N/Arabic/ArKeySwap; /** * This PHP class convert keyboard language programmatically (English - Arabic) * * @category I18N * @package Arabic * @author Khaled Al-Shamaa * @copyright 2006-2010 Khaled Al-Shamaa * * @license LGPL * @link http://www.ar-php.org */ class ArKeySwap { // First 12 chars replaced by 1 Byte in Arabic keyboard // while rest replaced by 2 Bytes UTF8 protected static $swapEn = '{}DFL:"ZCV<>`qwertyuiop[]asdfghjkl;\'zxcvnm,./~QWERYIOPASHJKXNM?'; protected static $swapAr = '<>][/:"~}{,.ذضصثقفغعهخحجدشسيبلاتنمكطئءؤرىةوزظًٌَُّإ÷×؛ٍِأـ،ْآ’؟'; protected static $swapFr = '²azertyuiop^$qsdfghjklmù*