You are here:

Joomla CMS/Arabic to english numbers

Advertisement


Question
Hello Jochen Daum,

I've got a website that functions in both arabic and english, it give its users the capability to advertise  their products.

anyhow.. i have a problem.

i would like to make all the numbers that are in my website to be ONLY in english , for the record the users are able to enter number in arabic such as ١٢٣٤٥٦٧٨٩، but i want all arabic numbers that are input to convert automatically to english 123456789.

Thanks.

Answer
Hi Mohammed,

interesting question. I have a couple of questions, but I can give some generic advice independent of these answers.
- is this Joomla 1,5, 1.6 or 1.7?
- Do you use any translation features, such as of 1.7 or Joomfish?
- Is this content stored in Joomla Articles or somewhere else - such as Virtuemart(and does that place support content plugin processing like recent Virtuemart versions for example)?

I'm also assuming for simplicity that your database uses UTF8 encoding, as has your web server by default and the MySQL connection.

Generally, I recommend to not change content from its original state after input, so if your users enter numbers as ١٢ then store it like this. Similarly, if they use 123, store it like this.

You have 2 option that I can think off immediately:

- find a "character translation" plugin on the Joomla Extension directory
- write one

For the latter option the code would roughly go like this for a content plugin:


class  plgYourPluginName extends JPlugin {


  function plgContentFormatForms(& $subject, $config) {
     parent::__construct($subject, $config);

     //load the translation
     $this->loadLanguage( );
  }

  function onBeforeDisplayContent( &$article, &$params, $limitstart ){
     global $mainframe;

     $application   = &JFactory::getApplication();
         $document   = &JFactory::getDocument();
     $doctype   = $document->getType();

         if ($application->isAdmin() || $doctype == 'raw') {
        return;
     }

     $article->text = strtr($article->text,'١٢٣٤٥٦٧٨٩','123456789');
       }
}

Also you need to insert a record into the database like this:


INSERT INTO `jos_plugins` (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES
('Content - translate Arabic numbers', 'yourPluginName', 'content', 0, 10000, 1, 1, 0, 0, '0000-00-00 00:00:00', ');


Hope this helps.

Joomla CMS

All Answers


Answers by Expert:


Ask Experts

Volunteer


Jochen Daum

Expertise

From a technology perspective, I can answer questions - as they relate to the Joomla CMS: - Browser compatibility, specifically, as they relate to modern browser versions of Internet Explorer, Firefox, Chrome and Apple Safari, but also related to Mobile phone technology, RSS feeds and related Internet technologies - Site layout planning, such as with wireframes - Content planning including how to set up categories, subcategories, sections and the like - User access control planning and implementation - Image, file, video (Youtube) and link management - E-Commerce including product categories, products, product pricing including multiple pricing categories for retail customers, wholesale and resellers - Intranet and other set-ups that require login - image galleries, banner management and other mass image management facilities In regards to specific Joomla components we can asnwer questions regarding - Virtuemart, formerly phpShop, but also general advice in regards to E-Commerce components - Jevents, but also general advice in regards to Events management, including for the music industry - RSForm, but also general advice in regards to form management components - Joomfish, but also topics of IP Address detection, country targeting and other techniques to show content dependend on user location and profile - Twitter, Facebook and Linkedin integration - Custom integration with any other computer system - Custom database integration - Ignite Gallery, but also other image galleries - Custom development of templates, components (such as calculators), modules and plugins - Developer advice on how to manage source code, backups, servers and related technologies

Experience

I have been developing websites for Mambo and then Joomla since 2003. We currently manage a portfolio of several large scale Joomla installations for major businesses, which are world-leaders in their specific markets. Furthermore, have provided mentoring services to Joomla component developers and advise developers and businesses alike on long term development strategies and management of source code, features, backups and intellectual property.

Organizations
Linkedin, Xing, BNI

Education/Credentials
I hold a Masters degree, computer science from Darmstadt University of Technology, Germany. My majors were Crypography, Databases, Software Engineering and computer networks. More importantly, I have been a passionate and successful business owner of a web development company, Automatem, now into its 7th year.

Past/Present Clients
Academic Colleges Group www.acgedu.com Philips Selecon www.seleconlight.com

©2016 About.com. All rights reserved.