RTL
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.
Installation
Add this line to your application's Gemfile:
gem 'rtl'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rtl
Usage
Query a language by string or symbol:
require 'rtl'
Rtl.rtl? 'ar' #=> true
Rtl.rtl? :ara #=> true
Query a language by ISO 639 code, (the default) ..
Rtl.rtl? :syc, :iso_code #=> true
Rtl.rtl? :eng #=> false
Or by ISO 15924 code ..
Rtl.rtl? 'Hung', :iso_long_code #=> true
Or by ISO number ..
Rtl.rtl? 130, :iso_number #=> true
Or by unicode alias ..
Rtl.rtl? 'Hebrew', :unicode_alias #=> true
Or by full name ..
Rtl.rtl? :Persian, :full_name #=> true
Or check all ways ..
Rtl.rtl? :kur, :all #=> true
Which is the default, in case no scheme criteria is specified.
Get List of all languages by any of the above criteria:
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
#=> ...
Useful Links
- 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)?
Contributing
Bug reports and pull requests are very much appreciated at Github.
License
The gem is available as open source under the terms of the MIT License.