Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
panvourtsis committed Aug 22, 2016
0 parents commit b348e45
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/greeklishTranslate.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Greeklish JS Translator
My implementation to interpet english to greek. Now you can change greeklish words to greek.

Enjoy!

### Demo Initialization
```js
greeklishTranslate("Parakalw");
```

### Version
1.0.0
82 changes: 82 additions & 0 deletions greeklishTranslate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Created by panagiotisvourtsis
*/
(function(window) {
"use strict";

function greeklishTranslate(s) {
var translateMap = {
"ks": "ξ",
"ps": "ψ",
"th": "θ",
"a": "α",
"b": "β",
"c": "σ",
"d": "δ",
"e": "ε",
"f": "φ",
"g": "γ",
"h": "η",
"i": "ι",
"k": "κ",
"l": "λ",
"m": "μ",
"n": "ν",
"o": "ο",
"p": "π",
"q": "",
"r": "ρ",
"s": "σ",
"t": "τ",
"u": "υ",
"v": "β",
"w": "ω",
"x": "χ",
"y": "υ",
"z": "ζ",
"KS": "Ξ",
"PS": "Ψ",
"TH": "Θ",
"A": "Α",
"B": "Β",
"C": "Σ",
"D": "Δ",
"E": "Ε",
"F": "Φ",
"G": "Γ",
"H": "Η",
"I": "Ι",
"K": "Κ",
"L": "Λ",
"M": "Μ",
"N": "Ν",
"O": "Ο",
"P": "Π",
"Q": "",
"R": "Ρ",
"S": "Σ",
"T": "Τ",
"U": "Υ",
"V": "Β",
"W": "Ω",
"X": "Χ",
"Y": "Υ",
"Z": "Ζ"
};

var newText = "";
for (var x = 0; x < s.length; x++) {
if (translateMap[s.charAt(x-1)+ s.charAt(x)] && x > 0) { //special case
newText = newText.substr(0, newText.length - 1);
newText += translateMap[s.charAt(x-1) + s.charAt(x)] || s.charAt(x);

} else {
newText += translateMap[s.charAt(x)] || s.charAt(x);
}
}

return newText;
}

window.greeklishTranslate = greeklishTranslate;
}(window));
13 changes: 13 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>testing greeklish</title>
<script src="greeklishTranslate.js"></script>
</head>
<body>
<script>
document.write(greeklishTranslate("Parakalw"));
</script>
</body>
</html>

0 comments on commit b348e45

Please sign in to comment.