Sep 29

Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by adding locale-specific components and translating text.

Due to the length of the words, the terms are frequently abbreviated to the numeronyms i18n (where 18 stands for the number of letters between the first i and last n in internationalization, a usage coined at DEC in the 1970s or 80s[1]) and L10n respectively. The capital L in L10n helps to distinguish it from the lowercase i in i18n.

Internationalization and localization instructions

Basic Terms

pot-file: Text file automatically generated with rake task (rake updatepo) or rgettext that shows all the original messages (msgid) inside the app code. Developers should generate this files and send them to translators as a template to write the po files (translated version of the pot file for a language).

po-file: Text file which is language-specific. It includes msgid(Original message) and msgstr(Translated message)

mo-file: Binary Files which are created from po-files with rake task (rake makemo) or rmsgfmt. The Ruby-GetText-Package library reads this compiled mo-files, not po-files.

File Maintenance

To do I18n maintenance, you need to install ruby-gettext-package

As it is not in the gem repository, you need to:
1) Download ruby-gettext-package- from here
2) Extract ruby-gettext-package-
3) Go to the extracted directory and run “sudo ruby setup.rb”

How to add a new language?:

1) create language directory inside “po” folder (eg: es/)
2) Go inside new language folder and run: msginit -i ../ur_application_name.pot -o ur_application_name.po

How to update po files (when new keys are added or modified)?:
1) Go to app folder and run: rake updatepo

To recompile files (when you get new/modifed po files translated)
1) Go to app folder and run: rake makemo

How to add i18n to a Page?


Basics

If you want to translate a text. Eg. “This text” You need to simple call _(). E.g _(“This text”).

The key will be added to the po file and someone will translate it later. If the key is already in the po file (and compiled in the mo file) it will appear translated. You should choose keys that make sense and that might be reusable. Try not to pick very long texts as keys.

Model: All field names are automatically added to the po file from the database (whith the rake task). If you need to define constants or translate new error messages, you can use the N_() function. For more information, check: http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html

written by admin

May 21

will_paginate‘ is one of the most widely used plugins in most of the ruby on rails projects.will_paginate is an alternative to the classic_pagination plugin, which is the pagination plugin that basically took the pre Rails 2.0 pagination implementation and packaged it in plugin form
1.How to Install will_paginate
the simple method
gem install mislav-will_paginate

There are some other method you can find it here.

2.Example

In controller
@gallery=Gallery.find(:all,:order=>”position asc”).paginate :page => page,:per_page=>10

where :per_page passes the number of gallery you want to display.You can change it according to your need 1-100
will_paginate defines it to be 30 by default

In View

you can simply use

<%= will_paginate @gallery %>
some advanced …

<% if @gallery.previous_page %>
<%= will_paginate @gallery,:page_links=>false, :next_label => “”, :prev_label => image_tag(“/images/icon/arrow.png”, :border => “0″) %>
<% end %>

<% if @gallery.next_page %>
<%= will_paginate @gallery,:page_links=>false, :next_label => image_tag(“/images/icon/arrow.png”,, :border => “0″), :prev_label => “” %>
<% end %>

If we put page_links=>false then it won’t display 1,2,3… and next_label and prev_label => “” as null it won’t display Next and Prev

Ryan Bates made an awesome screencast check it out here

written by admin

Oct 13

How to install Ruby on Rails In Linux

$ su -
# yum install ruby ruby-rdoc ruby-irb

Note: If you get an error, similar to the following, just wait a while and try the above command again.

Loading “installonlyn” plugin
Existing lock /var/run/yum.pid: another copy is running as pid 2321. Aborting.

Note: If you get something similar to the following, just enter y.

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2
Importing GPG key 0x4F2A6FD2 “Fedora Project ” from /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
Is this ok [y/N]:

Install RubyGems via source

Note: Note: Latest version of RubyGems (1.3.3) .
Enter into the Terminal:

cd /tmp
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar -zxvf rubygems-0.9.4.tgz
cd rubygems-0.9.4
# ruby setup.rb

Install Ruby on Rails using RubyGems

Enter into the Terminal:

# gem install -y rails

To check the installed gems on your local machine
gem list –local

written by rubyfreaks

Jul 10

Ruby on Rails

Ruby on Rails is an open source web application framework for the Ruby programming language. It is often referred to as Rails or RoR . It is intended to be used with the Agile development methodology, which is often utilized by web developers for its suitability for short, client-driven projects.

Some Cool links

Books for Ruby on Rails

Rails Framework Documentation

written by rubyfreaks \\ tags: , , ,