Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Greek to Greeklish Javascript Function by Nicolas Lagios - Rocket Path P.C.
- function replaceGreekCharacters(txt) {
- const greekToLatinMap = {
- //μικρά ελληνικά
- "α": "a","β": "b",
- "γ": "g","δ": "d",
- "ε": "e","ζ": "z",
- "η": "h","θ": "th",
- "ι": "i","κ": "k",
- "λ": "l","μ": "m",
- "ν": "n","ξ": "x",
- "ο": "o","π": "p",
- "ρ": "r","σ": "s",
- "τ": "t","υ": "y",
- "φ": "ph","χ": "ch",
- "ψ": "ps","ω": "w",
- //μικρά με τόνους
- "ά": "a","έ": "e",
- "ή": "h","ί": "i",
- "ό": "o","ύ": "y",
- "ώ": "w",
- //κεφαλαία ελληνικά
- "Α": "A","Β": "B",
- "Γ": "G","Δ": "D",
- "Ε": "E","Ζ": "Z",
- "Η": "H","Ρ": "TH",
- "Ι": "I","Κ": "K",
- "Λ": "L","Μ": "M",
- "Ν": "N","Ξ": "X",
- "Ο": "O","Π": "P",
- "Ρ": "R","Σ": "S",
- "Τ": "T","Υ": "Y",
- "Φ": "PH","Χ": "CH",
- "Ψ": "PS","Ω": "W",
- //κεφαλαία με τόνους
- "Ά": "A","Έ": "E",
- "Ή": "H","Ί": "I",
- "Ό": "O","Ύ": "Y",
- "Ώ": "W",
- };
- for (const greekCharacter in greekToLatinMap) {
- txt = txt.replace(greekCharacter, greekToLatinMap[greekCharacter]);
- }
- return txt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement