Module: Rtl

Defined in:
lib/rtl/core.rb,
lib/rtl/version.rb

Constant Summary collapse

FULL_NAMES =

Formal full names for RTL languages.

["Adlam", "Arabic", "Arabic (Nastaliq variant)", "Imperial Aramaic", "Avestan",
"Cypriot", "Egyptian demotic", "Egyptian hieratic", "Hatran", "Hebrew",
"Old Hungarian (Hungarian Runic)", "Indus (Harappan)", "Kharoshthi", "Lydian",
"Mandaic, Mandaean", "Manichaean", "Mende Kikakui", "Meroitic Cursive",
"Meroitic Hieroglyphs", "Old North Arabian (Ancient North Arabian)",
"Nabataean", "N’Ko", "Old Turkic, Orkhon Runic", "Palmyrene",
"Inscriptional Pahlavi", "Psalter Pahlavi", "Book Pahlavi", "Phoenician",
"Inscriptional Parthian", "Samaritan", "Old South Arabian", "Syriac",
"Syriac (Estrangelo variant)", "Syriac (Western variant)",
"Syriac (Eastern variant)", "Thaana", "Woleai", "Persian", "Kurdish", "Urdu",
"Pashto (Pushto)", "Yiddish"]
ISO_CODES =

ISO 639 codes for RTL languages. If a language has 639-1 and 639-2 codes, both are included.

["ar", "ara", "arc", "ae", "ave", "egy", "he", "heb", "nqo", "pal", "phn", "sam",
"syc", "syr", "fa", "per", "fas", "ku", "kur", "ur", "urd", "pus", "ps", "yi", "yid"]
ISO_LONG_CODES =

ISO 15924 codes for RTL languages.

['Adlm', 'Arab', 'Aran', 'Armi', 'Avst', 'Cprt', 'Egyd', 'Egyh', 'Hatr',
'Hebr', 'Hung', 'Inds', 'Khar', 'Lydi', 'Mand', 'Mani', 'Mend', 'Merc',
'Mero', 'Narb', 'Nbat', 'Nkoo', 'Orkh', 'Palm', 'Phli', 'Phlp', 'Phlv',
'Phnx', 'Prti', 'Samr', 'Sarb', 'Syrc', 'Syre', 'Syrj', 'Syrn', 'Thaa',
'Wole']
ISO_NUMBERS =

ISO 15924 numbers for RTL languages.

['166', '160', '161', '124', '134', '403', '070', '060', '127', '125', '176',
'610', '305', '116', '140', '139', '438', '101', '100', '106', '159', '165',
'175', '126', '131', '132', '133', '115', '130', '123', '105', '135', '138',
'137', '136', '170', '480']
UNICODE_ALIASES =

Unicode alias names for RTL languages. Not all ISO languages has this alias.

["Adlam", "Arabic", "Imperial Aramaic", "Avestan", "Cypriot",
"Hatran", "Hebrew", "Old Hungarian", "Kharoshthi", "Lydian", "Mandaic",
"Manichaean", "Mende Kikakui", "Meroitic Cursive", "Meroitic Hieroglyphs",
"Old North Arabian", "Nabataean", "NKo", "Old Turkic", "Palmyrene",
"Inscriptional Pahlavi", "Psalter Pahlavi", "Phoenician",
"Inscriptional Parthian", "Samaritan", "Old South Arabian", "Syriac",
"Thaana"]
VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.rtl?(language, scheme = :all) ⇒ Boolean

Query whether a language is rtl or not.

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rtl/core.rb', line 44

def self.rtl? language, scheme = :all
  sch = scheme.to_sym
  l = language.to_s.strip

  case sch
    when :iso_code
      self.iso_codes l
    when :iso_long_code
      self.iso_long_codes l
    when :iso_number
      self.iso_numbers l
    when :unicode_alias
      self.unicode_aliases l
    when :full_name
      self.full_names l
    when :all
      self.all l
    else
      raise ArgumentError.new "Unknown scheme value #{scheme}."
  end
end

.rtl_languages(scheme = :iso_code) ⇒ Object

Get a list of languages by scheme



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rtl/core.rb', line 67

def self.rtl_languages scheme = :iso_code
  sch = scheme.to_s
  s = sch.end_with?('s') ? 'ES' : 'S'
  member = "#{sch.upcase}#{s}".to_sym

  begin
    self.const_get member
  rescue NameError
    raise ArgumentError.new "Unknown Supplied scheme #{scheme}."
  end
end