After working on several Ruby on Rails projects in Arabic lately I ended up repeating some functionality to support Arabic localization, specially on the Model and View levels so I decided to create a plugin for that, and I called it ArabicHelper.
I’ve been also following the updates in rails-I18n and did some work on the Arabic locale file, you can find it here. You can simply use it if you are on Rails 2.2 or Rails Edge, or if you are not then use ArabicHelper.
ArabicHelper
A plugin to help you localize your Rails app to Arabic, this include few useful helpers and ActiveRecord localization
Arabic Helper consists of two parts, model extension and views helper methods. Model extension is to help you have Arabic error messages and attributes names in your model. Helper methods are made to support, pluralizing, country names and time distance in Arabic.
Example
Model extension:
class Post
has_arabic_attributes :body => 'النص',
:user_id => 'الكاتب'
end
View/Controller
@post = Post.first @post.arabic_full_messages
Available helpers:
arabic_country_options_for_select arabic_time_ago_in_words(from_time, include_seconds = false) arabic_distance_of_time_in_words(from_time, to_time = 0, include_seconds = false) arabic_pluralize(number, singular, double, plural, gender_class='male')
Install the plugin:
./script/plugin install git://github.com/rbarazi/arabic_helper.git

Moski Doski said..
Really cool idea, will give it a shot today and see how it goes.
on October 13th at 10:50 amThanx
waseem said..
Excellent work and you I recommend you to change PHP
on October 13th at 11:24 amwaseem said..
Would not need to reinvent the wheel again
on October 13th at 11:25 amdotone said..
Yo, remember the dot1_ol? It’d be a great combo if the OL tags get arabized on the fly using JS using your plug-in. That way, even when the header sent is en-US or whatever, on Arabic pages OL tags show arabic numbers/formats. If you’re positive on this I can rework out the experimental JS-Class and turn it into a production version. Here’s the dot1_ol
on October 13th at 4:45 pmRida said..
@Moski Doski: Thanks, please let me know of any suggestions you may have.
@waseem: I’m sorry but I didn’t really get what you mean :)
@dotone: Sure man, I looked into it yesterday, it would be great if you can work on a production version. I’ll added it once it’s ready.. That would be really cool :D
on October 14th at 12:00 pmshuaib said..
Dear Rida, Thanks for the great work. I am using this plugin now and it is helpful.
I am wondering about some implementations.
when I want to validate the fields of the form, I use error_messages_for. which will use the default rails error message output. How can we use arabic_full_messages to do the same. I made that manually
http://pastie.org/295596
to give me the proper output. Am I missing the way or something in the plugin or you still did not implement that.
Thanks
on October 19th at 9:42 amshuaib said..
Well, i needed to use your plugin
you may click add the ad to see the error message I mean.
http://www.shobiddak.com/stuffs/new
I implemented it like this
http://pastie.org/295603
I noticed that when I use
on October 19th at 10:45 amvalidates presence of, the output will be in arabic but the column name is not arabized??
Rida said..
@shuaib I’m glad you found the plugin useful, I’ll soon add support for error_messages_for and will post the update here.
on October 26th at 12:02 pmRida Al Barazi » Blog Archive » Testing your Rails plugin said..
[...] I first released both ArabicHelper and SimplySearchable I didn’t have any tests for them because I didn’t know the right [...]
on November 18th at 11:00 pm