Create CakePHP application with Arabic language support

Arabic Webpage

CakePHP is  a  framework for PHP that helps us to create developing with more security based web applications , cakePHP is famous for their MVC (Model–View–Controlle)  and  ORM (Object-relational mapping ) last two article we discussed how to create static pages creation, cakePHP installation and its properties. This article explains how we can create an Arabic website or Arabic language support with cakePHP .

With the help of UTF-8 (8-bit UCS/Unicode Transformation Format)  Arabic font  dream comes  alive . UTF-8  variable-length character encoding for Unicode .Unicode is a computing industry standard , nowadays it is used for e-mail’s and  web pages.

CakePHP

configuring cakePHP  : app\config folder databse.php
last article I explained how to configure cake php
var $default = array(
‘driver’ => ‘mysql’,
‘persistent’ => false,
‘host’ => ‘localhost’,
‘login’ => ‘root’,
‘password’ => ”,
‘database’ => ‘arabic_demo’,
‘encoding’ => ‘UTF8′,
‘prefix’ => ”,
);
under default please add new line  ’encoding’ => ‘UTF8′, now our system turn to UTF8 support now we can use all languages in cakePHP .
in case of Arabic we all know it writing from right to left and all the Arabic site scroll bar you can view in left side  for that we need to do some changes in layout ,
in cakePHP we create template layout under app\views\layouts default.ctp file – and its header please replace with  bellow html headers headers
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html dir=”rtl” lang=”arabic”>
with the help of this tag we are creating html arabic pages, dir=”rtl” to the html tag any time the overall document direction is right-to-left. This sets the base direction for the whole document.
* No dir attribute is needed for documents that have a base direction of left-to-right, since this is the default.
And include utf8 meta tag  on header
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8″>
It helps to send the ‘charset’ parameter in the Content-Type header of HTTP

Mysql

create a data base

“CREATE DATABASE `arabic_demo` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; “ and databse default character defind as utf 8

Database Creating

and Icreated article named table  as an example

CREATE TABLE `arabic_demo`.`arcicle` (

`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,

`title` VARCHAR( 200 ) NOT NULL ,

`description` LONGTEXT NOT NULL ,

`status` ENUM( ‘A’, ‘D’ ) NOT NULL DEFAULT ‘A’,

`created` DATETIME NOT NULL ,

`modified` DATETIME NOT NULL ,

PRIMARY KEY ( `id` )

) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci

with character set utf8  and same you  have to follow in utf8 Unicode table or database creating time

Now your system is ready to run an Arabic language application …

Both comments and pings are currently closed.

4 Responses to “Create CakePHP application with Arabic language support”

  1. Lenin says:

    This article seems very helpfull, thanks Zam…………

  2. Ala says:

    Nice ,helped me alot in my college assignement. Say thank you for your information.

  3. ultrasound technician says:

    This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

  4. Asdasd says:

    Great article Thank

    you so much!