-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (29 loc) · 869 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import lang from './languages.js'
const arm = lang.arm
const ru = lang.ru
const uk = lang.uk
const bul = lang.bul
const SupLanObj = { "uk": uk, "bul": bul }
function translit(value, opt) {
let translitText = ""
let arr = value.toLowerCase().split("")
if (!opt) {
for (let i of arr) {
if (arm[i] !== undefined) {
translitText += arm[i]
} else if (ru[i] !== undefined) {
translitText += ru[i]
}
else translitText += i
}
} else {
if (opt in SupLanObj) {
let lanObj = SupLanObj[opt]
for (let i of arr) {
(lanObj[i] !== undefined) ? translitText += lanObj[i] : translitText += i
}
} else translitText = "this language not supported!";
}
return translitText
}
export default translit