Class: Arabic

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/arabic.rb

Constant Summary collapse

ARABIC =
{
    '،' => ',',   # ARABIC COMMA
    '؛' => ';',   # ARABIC SEMICOLON
    '؟' => '?',   # ARABIC QUESTION MARK
    'ء' => "'",   # ARABIC LETTER HAMZA
    'آ' => 'a',   # ARABIC LETTER ALEF WITH MADDA ABOVE
    'أ' => 'a',   # ARABIC LETTER ALEF WITH HAMZA ABOVE
    'ؤ' => 'w',   # ARABIC LETTER WAW WITH HAMZA ABOVE
    'إ' => 'i',   # ARABIC LETTER ALEF WITH HAMZA BELOW
    'ئ' => 'ye',  # ARABIC LETTER YEH WITH HAMZA ABOVE
    'ا' => 'a',   # ARABIC LETTER ALEF
    'ب' => 'b',   # ARABIC LETTER BEH
    'ة' => 'a',   # ARABIC LETTER TEH MARBUTA
    'ت' => 't',   # ARABIC LETTER TEH
    'ث' => 'th',  # ARABIC LETTER THEH
    'ج' => 'j',   # ARABIC LETTER JEEM
    'ح' => 'h',   # ARABIC LETTER HAH
    'خ' => 'kh',  # ARABIC LETTER KHAH
    'د' => 'd',   # ARABIC LETTER DAL
    'ذ' => 'th',  # ARABIC LETTER THAL
    'ر' => 'r',   # ARABIC LETTER REH
    'ز' => 'z',   # ARABIC LETTER ZAIN
    'س' => 's',   # ARABIC LETTER SEEN
    'ش' => 'sh',  # ARABIC LETTER SHEEN
    'ص' => 's',   # ARABIC LETTER SAD
    'ض' => 'd',   # ARABIC LETTER DAD
    'ط' => 't',   # ARABIC LETTER TAH
    'ظ' => 'z',   # ARABIC LETTER ZAH
    'ع' => "'",   # ARABIC LETTER AIN
    'غ' => 'gh',  # ARABIC LETTER GHAIN
    'ـ' => '-',   # ARABIC TATWEEL
    'ف' => 'f',   # ARABIC LETTER FEH
    'ق' => 'q',   # ARABIC LETTER QAF
    'ك' => 'k',   # ARABIC LETTER KAF
    'ل' => 'l',   # ARABIC LETTER LAM
    'م' => 'm',   # ARABIC LETTER MEEM
    'ن' => 'n',   # ARABIC LETTER NOON
    'ه' => 'h',   # ARABIC LETTER HEH
    'و' => 'w',   # ARABIC LETTER WAW
    'ى' => 'a',   # ARABIC LETTER ALEF MAKSURA
    'ي' => 'y',   # ARABIC LETTER YEH
    'َ' => 'a',    # ARABIC FATHA
    'ُ' => 'u',    # ARABIC DAMMA
    'ِ' => 'i',    # ARABIC KASRA
    'ْ' => '',     # ARABIC SUKUN
    'ٔ' => "'",    # ARABIC HAMZA ABOVE
    'ٕ' => "'",    # ARABIC HAMZA BELOW
    '٠' => '0',   # ARABIC-INDIC DIGIT ZERO
    '١' => '1',   # ARABIC-INDIC DIGIT ONE
    '٢' => '2',   # ARABIC-INDIC DIGIT TWO
    '٣' => '3',   # ARABIC-INDIC DIGIT THREE
    '٤' => '4',   # ARABIC-INDIC DIGIT FOUR
    '٥' => '5',   # ARABIC-INDIC DIGIT FIVE
    '٦' => '6',   # ARABIC-INDIC DIGIT SIX
    '٧' => '7',   # ARABIC-INDIC DIGIT SEVEN
    '٨' => '8',   # ARABIC-INDIC DIGIT EIGHT
    '٩' => '9',   # ARABIC-INDIC DIGIT NINE
    '٪' => '%',   # ARABIC PERCENT SIGN
    '٫' => ' => ',  # ARABIC DECIMAL SEPARATOR
    '٬' => ' => ',  # ARABIC THOUSANDS SEPARATOR
    'ٮ' => 'b',   # ARABIC LETTER DOTLESS BEH
    'ٯ' => 'q',   # ARABIC LETTER DOTLESS QAF
    'ٰ' => 'a',   # ARABIC LETTER SUPERSCRIPT ALEF
    'ٱ' => 'a',   # ARABIC LETTER ALEF WASLA
    'ٲ' => 'a',   # ARABIC LETTER ALEF WITH WAVY HAMZA ABOVE
    'ٳ' => 'a',   # ARABIC LETTER ALEF WITH WAVY HAMZA BELOW
    'ٷ' => 'u',   # ARABIC LETTER U WITH HAMZA ABOVE
    'ٹ' => 'tt',  # ARABIC LETTER TTEH
    'ٺ' => 'tt',  # ARABIC LETTER TTEHEH
    'ٻ' => 'b',   # ARABIC LETTER BEEH
    'ټ' => 't',   # ARABIC LETTER TEH WITH RING
    'ٽ' => 't',   # ARABIC LETTER TEH WITH THREE DOTS ABOVE DOWNWARDS
    'پ' => 'p',   # ARABIC LETTER PEH
    'ٿ' => 't',   # ARABIC LETTER TEHEH
    'ڀ' => 'b',   # ARABIC LETTER BEHEH
    'ځ' => 'h',   # ARABIC LETTER HAH WITH HAMZA ABOVE
    'ڂ' => 'h',   # ARABIC LETTER HAH WITH TWO DOTS VERTICAL ABOVE
    'ڃ' => 'ny',  # ARABIC LETTER NYEH
    'ڄ' => 'dy',  # ARABIC LETTER DYEH
    'څ' => 'h',   # ARABIC LETTER HAH WITH THREE DOTS ABOVE
    'چ' => 'tch',   # ARABIC LETTER TCHEH
    'ڇ' => 'tch',   # ARABIC LETTER TCHEHEH
    'ڈ' => 'dd',  # ARABIC LETTER DDAL
    'ډ' => 'd',   # ARABIC LETTER DAL WITH RING
    'ڊ' => 'd',   # ARABIC LETTER DAL WITH DOT BELOW
    'ڋ' => 'd',   # ARABIC LETTER DAL WITH DOT BELOW AND SMALL TAH
    'ڌ' => 'd',   # ARABIC LETTER DAHAL
    'ڍ' => 'dd',  # ARABIC LETTER DDAHAL
    'ڎ' => 'd',   # ARABIC LETTER DUL
    'ڏ' => 'd',   # ARABIC LETTER DAL WITH THREE DOTS ABOVE DOWNWARDS
    'ڐ' => 'd',   # ARABIC LETTER DAL WITH FOUR DOTS ABOVE
    'ڑ' => 'rr',  # ARABIC LETTER RREH
    'ڒ' => 'r',   # ARABIC LETTER REH WITH SMALL V
    'ړ' => 'r',   # ARABIC LETTER REH WITH RING
    'ڔ' => 'r',   # ARABIC LETTER REH WITH DOT BELOW
    'ڕ' => 'r',   # ARABIC LETTER REH WITH SMALL V BELOW
    'ږ' => 'r',   # ARABIC LETTER REH WITH DOT BELOW AND DOT ABOVE
    'ڗ' => 'r',   # ARABIC LETTER REH WITH TWO DOTS ABOVE
    'ژ' => 'j',   # ARABIC LETTER JEH
    'ڙ' => 'r',   # ARABIC LETTER REH WITH FOUR DOTS ABOVE
    'ښ' => 's',   # ARABIC LETTER SEEN WITH DOT BELOW AND DOT ABOVE
    'ڛ' => 's',   # ARABIC LETTER SEEN WITH THREE DOTS BELOW
    'ڜ' => 's',   # ARABIC LETTER SEEN WITH THREE DOTS BELOW AND THREE DOTS ABOVE
    'ڝ' => 's',   # ARABIC LETTER SAD WITH TWO DOTS BELOW
    'ڞ' => 's',   # ARABIC LETTER SAD WITH THREE DOTS ABOVE
    'ڟ' => 't',   # ARABIC LETTER TAH WITH THREE DOTS ABOVE
    'ڠ' => 'n',   # ARABIC LETTER AIN WITH THREE DOTS ABOVE
    'ڡ' => 'f',   # ARABIC LETTER DOTLESS FEH
    'ڢ' => 'f',   # ARABIC LETTER FEH WITH DOT MOVED BELOW
    'ڣ' => 'f',   # ARABIC LETTER FEH WITH DOT BELOW
    'ڤ' => 'v',   # ARABIC LETTER VEH
    'ڥ' => 'f',   # ARABIC LETTER FEH WITH THREE DOTS BELOW
    'ڦ' => 'p',   # ARABIC LETTER PEHEH
    'ڧ' => 'q',   # ARABIC LETTER QAF WITH DOT ABOVE
    'ڨ' => 'q',   # ARABIC LETTER QAF WITH THREE DOTS ABOVE
    'ک' => 'k',   # ARABIC LETTER KEHEH
    'ڪ' => 'k',   # ARABIC LETTER SWASH KAF
    'ګ' => 'k',   # ARABIC LETTER KAF WITH RING
    'ڬ' => 'k',   # ARABIC LETTER KAF WITH DOT ABOVE
    'ڭ' => 'ng',  # ARABIC LETTER NG
    'ڮ' => 'k',   # ARABIC LETTER KAF WITH THREE DOTS BELOW
    'گ' => 'g',   # ARABIC LETTER GAF
    'ڰ' => 'g',   # ARABIC LETTER GAF WITH RING
    'ڱ' => 'ng',  # ARABIC LETTER NGOEH
    'ڲ' => 'g',   # ARABIC LETTER GAF WITH TWO DOTS BELOW
    'ڳ' => 'g',   # ARABIC LETTER GUEH
    'ڴ' => 'g',   # ARABIC LETTER GAF WITH THREE DOTS ABOVE
    'ڵ' => 'l',   # ARABIC LETTER LAM WITH SMALL V
    'ڶ' => 'l',   # ARABIC LETTER LAM WITH DOT ABOVE
    'ڷ' => 'l',   # ARABIC LETTER LAM WITH THREE DOTS ABOVE
    'ڸ' => 'l',   # ARABIC LETTER LAM WITH THREE DOTS BELOW
    'ڹ' => 'n',   # ARABIC LETTER NOON WITH DOT BELOW
    'ں' => 'n',   # ARABIC LETTER NOON GHUNNA
    'ڻ' => 'rn',  # ARABIC LETTER RNOON
    'ڼ' => 'n',   # ARABIC LETTER NOON WITH RING
    'ڽ' => 'n',   # ARABIC LETTER NOON WITH THREE DOTS ABOVE
    'ھ' => 'h',   # ARABIC LETTER HEH DOACHASHMEE
    'ڿ' => 'tch', # ARABIC LETTER TCHEH WITH DOT ABOVE
    'ۀ' => 'h',   # ARABIC LETTER HEH WITH YEH ABOVE
    'ہ' => 'h',   # ARABIC LETTER HEH GOAL
    'ۂ' => 'h',   # ARABIC LETTER HEH GOAL WITH HAMZA ABOVE
    'ۃ' => 'a',   # ARABIC LETTER TEH MARBUTA GOAL
    'ۄ' => 'w',   # ARABIC LETTER WAW WITH RING
    'ۅ' => 'oe',  # ARABIC LETTER KIRGHIZ OE
    'ۆ' => 'oe',  # ARABIC LETTER OE
    'ۇ' => 'u',   # ARABIC LETTER U
    'ۈ' => 'yu',  # ARABIC LETTER YU
    'ۉ' => 'yu',  # ARABIC LETTER KIRGHIZ YU
    'ۊ' => 'w',   # ARABIC LETTER WAW WITH TWO DOTS ABOVE
    'ۋ' => 'v',   # ARABIC LETTER VE
    'ی' => 'y',   # ARABIC LETTER FARSI YEH
    'ۍ' => 'y',   # ARABIC LETTER YEH WITH TAIL
    'ێ' => 'y',   # ARABIC LETTER YEH WITH SMALL V
    'ۏ' => 'w',   # ARABIC LETTER WAW WITH DOT ABOVE
    'ې' => 'e',   # ARABIC LETTER E
    'ۑ' => 'y',   # ARABIC LETTER YEH WITH THREE DOTS BELOW
    'ے' => 'y',   # ARABIC LETTER YEH BARREE
    'ۓ' => 'y',   # ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
    '۔' => '.',   # ARABIC FULL STOP
    'ە' => 'ae',  # ARABIC LETTER AE
    'ۮ' => 'd',   # ARABIC LETTER DAL WITH INVERTED V
    'ۯ' => 'r',   # ARABIC LETTER REH WITH INVERTED V
    '۰' => '0',   # EXTENDED ARABIC-INDIC DIGIT ZERO
    '۱' => '1',   # EXTENDED ARABIC-INDIC DIGIT ONE
    '۲' => '2',   # EXTENDED ARABIC-INDIC DIGIT TWO
    '۳' => '3',   # EXTENDED ARABIC-INDIC DIGIT THREE
    '۴' => '4',   # EXTENDED ARABIC-INDIC DIGIT FOUR
    '۵' => '5',   # EXTENDED ARABIC-INDIC DIGIT FIVE
    '۶' => '6',   # EXTENDED ARABIC-INDIC DIGIT SIX
    '۷' => '7',   # EXTENDED ARABIC-INDIC DIGIT SEVEN
    '۸' => '8',   # EXTENDED ARABIC-INDIC DIGIT EIGHT
    '۹' => '9',   # EXTENDED ARABIC-INDIC DIGIT NINE
    'ۺ' => 'sh',  # ARABIC LETTER SHEEN WITH DOT BELOW
    'ۻ' => 'd',   # ARABIC LETTER DAD WITH DOT BELOW
    'ۼ' => 'gh',  # ARABIC LETTER GHAIN WITH DOT BELOW
    '۽' => '&',   # ARABIC SIGN SINDHI AMPERSAND
    '' => 'Allah',   # ARABIC LIGATURE ALLAH ISOLATED FORM
    'ۡ' => '',      # comment small high dotless head of khah; like sukun (no vowel); used in Kashmiri =>  Assamese
    'اً' => 'an',  # alef + fathatan
    'ً' => '',   # fathatan ("-an")
    'ٌ' => '',   # dammatan ("-un")
    'ٍ' => '',   # kasratan ("-in")
    'ّ' => '',     # shadda (consonant doubler)
    '۾' => 'men',   # Sindhi postposition men
    'ؑ' => 'alayhe wasallam',  # "upon him be peace"
    '' => 'Mohammad',      # "Mohammad"
    '' => 'wasallam',    # "and peace"
    '' => 'sallallahou alayhe wasallam',   # "prayer of God be upon him and his family and peace"
}.freeze

Class Method Summary collapse

Class Method Details

.t(text) ⇒ Object



193
194
195
196
197
# File 'lib/lib/arabic.rb', line 193

def self.t(text)
  latin = text.dup
  ARABIC.each { |k,v| latin.gsub!(k, v)}
  latin
end