This gem helps you check whether a language direction is right-to-left (RTL) or left-to-right (LTR) implicitly, by supplying its full name, iso code, or other options.
Add this line to your application's Gemfile:
gem 'rtl'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rtl
require 'rtl'
Rtl.rtl? 'ar' #=> true
Rtl.rtl? :ara #=> true
Rtl.rtl? :syc, :iso_code #=> true
Rtl.rtl? :eng #=> false
Rtl.rtl? 'Hung', :iso_long_code #=> true
Rtl.rtl? 130, :iso_number #=> true
Rtl.rtl? 'Hebrew', :unicode_alias #=> true
Rtl.rtl? :Persian, :full_name #=> true
Rtl.rtl? :kur, :all #=> true
Which is the default, in case no scheme criteria is specified.
Rtl.rtl_languages
#=> ["ar", "ara", "arc", "ae", "ave", "egy", "he", "heb", "nqo", "pal", "phn", "sam", "syc", "syr", "fa", "per", "fas", "ku", "kur"]
Rtl.rtl_languages :iso_long_code
#=> ...
- ISO 639-2 Language Code List - Codes for the representation of names of languages (Library of Congress).
- List of ISO 639-1 codes on Wikipedia.
- Right-to-left on Wikipedia.
- ISO 15924 on Wikipedia.
- Questions & Answers: Which languages are written right-to-left (RTL)?
Bug reports and pull requests are very much appreciated at Github.
The gem is available as open source under the terms of the MIT License.