-
Notifications
You must be signed in to change notification settings - Fork 0
/
ekler.js
127 lines (125 loc) · 6.36 KB
/
ekler.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function in_array(obj, arr) {
for(var i=0; i<arr.length; i++) {
if (arr[i] == obj) return true;
}
return false;
}
function suffixes(string,suffix,apostrof,apostrofMark){
var hardConsonantLetters = ['ç','f','h','k','p','s','ş','t'];
var matchesVowelLetters = string.match(/[aeıioöuü]/g);
var lastVowelLetter = matchesVowelLetters[matchesVowelLetters.length-1];
var lastLetter = string.charAt(string.length-1);
var stringSuffix = "";
if(apostrof === false){
apostrofMark = "";
}
switch(suffix){
case "in":
if(lastLetter == "a" || lastLetter == "ı"){
stringSuffix = "nın";
} else if(lastLetter == "e" || lastLetter == "i") {
stringSuffix = "nin";
} else if(lastLetter == "u" || lastLetter == "o") {
stringSuffix = "nun";
} else if(lastLetter == "ö" || lastLetter == "ü") {
stringSuffix = "nün";
} else if(lastVowelLetter == "a" || lastVowelLetter == "ı" ) {
stringSuffix = "ın";
} else if(lastVowelLetter == "e" || lastVowelLetter == "i") {
stringSuffix = "in";
} else if(lastVowelLetter == "u" || lastVowelLetter == "o") {
stringSuffix = "un";
} else if(lastVowelLetter == "ö" || lastVowelLetter == "ü" ) {
stringSuffix = "ün";
} else {
stringSuffix = "ın";
}
break;
case "e":
if(lastLetter == "a" || lastLetter == "ı" || lastLetter == "u" || lastLetter == "o"){
stringSuffix = "ya";
} else if(lastLetter == "e" || lastLetter == "i" || lastLetter == "ö" || lastLetter == "ü"){
stringSuffix = "ye";
} else if(lastVowelLetter == "a" || lastVowelLetter == "ı" || lastVowelLetter == "u" || lastVowelLetter == "o"){
stringSuffix = "a";
} else if(lastVowelLetter == "e" || lastVowelLetter == "i" || lastVowelLetter == "ö" || lastVowelLetter == "ü"){
stringSuffix = "e";
} else {
stringSuffix = "a";
}
break;
case "i":
if(lastLetter == "a" || lastLetter == "ı"){
stringSuffix = "yı";
} else if(lastLetter == "e" || lastLetter == "i"){
stringSuffix = "yi";
} else if(lastLetter =="u" || lastLetter == "o"){
stringSuffix = "yu";
} else if(lastLetter =="ö" || lastLetter == "ü"){
stringSuffix = "yü";
} else if(lastVowelLetter == "a" || lastVowelLetter == "ı"){
stringSuffix = "ı";
} else if(lastVowelLetter == "e" || lastVowelLetter == "i"){
stringSuffix = "i";
} else if(lastVowelLetter == "u" || lastVowelLetter == "o"){
stringSuffix = "u";
} else if(lastVowelLetter == "ü" || lastVowelLetter == "ö"){
stringSuffix = "ü";
}
break;
case "de":
if(lastLetter =="a" || lastLetter == "ı" || lastLetter == "u" || lastLetter == "o"){
stringSuffix ="da";
} else if(lastLetter == "e" || lastLetter == "i" || lastLetter == "ö" || lastLetter == "ü"){
stringSuffix ="de";
} else if(in_array(lastLetter, hardConsonantLetters) && (lastVowelLetter == "a" || lastVowelLetter =="ı" || lastVowelLetter==="u" || lastVowelLetter==="o") ){
stringSuffix = "ta";
} else if(in_array(lastLetter, hardConsonantLetters) && (lastVowelLetter == "e" || lastVowelLetter =="i" || lastVowelLetter=="ü" || lastVowelLetter=="ö") ){
stringSuffix = "te";
} else if(lastVowelLetter=="a" || lastVowelLetter == "ı" || lastVowelLetter == "u" || lastVowelLetter =="o"){
stringSuffix = "da";
} else if(lastVowelLetter=="e" || lastVowelLetter == "i" || lastVowelLetter == "ü" || lastVowelLetter == "ö"){
stringSuffix = "de";
} else if(in_array(lastLetter, hardConsonantLetters)){
stringSuffix = "ta";
} else {
stringSuffix = "da";
}
break;
case "den":
if(lastLetter == "a" || lastLetter == "ı" || lastLetter == "u" || lastLetter == "o"){
stringSuffix = "dan";
} else if(lastLetter == "e" || lastLetter == "i" || lastLetter == "ö" || lastLetter == "ü"){
stringSuffix = "den";
} else if(in_array(lastLetter, hardConsonantLetters) && (lastVowelLetter == "a" || lastVowelLetter == "ı" || lastVowelLetter == "u" || lastVowelLetter=="o") ){
stringSuffix = "tan";
} else if(in_array(lastLetter, hardConsonantLetters) && (lastVowelLetter == "e" || lastVowelLetter == "i" || lastVowelLetter == "ö" || lastVowelLetter=="ü") ){
stringSuffix = "ten";
} else if(lastVowelLetter == "a" || lastVowelLetter == "ı" || lastVowelLetter == "u" || lastVowelLetter == "o"){
stringSuffix = "dan";
} else if(lastVowelLetter == "e" || lastVowelLetter == "i" || lastVowelLetter == "ö" || lastVowelLetter == "ü"){
stringSuffix = "den";
} else if(in_array(lastLetter, hardConsonantLetters)){
stringSuffix = "tan";
} else {
stringSuffix = "dan";
}
break;
case "ile":
apostrofMark = "";
if(lastLetter == "a" || lastLetter == "ı" || lastLetter == "u" || lastLetter == "o"){
stringSuffix = "yla";
} else if(lastLetter == "e" || lastLetter == "i" || lastLetter == "ö" || lastLetter == "ü"){
stringSuffix = "yle";
} else if(lastVowelLetter == "a" || lastVowelLetter == "ı" || lastVowelLetter == "u" || lastVowelLetter == "o"){
stringSuffix = "la";
} else if(lastVowelLetter == "e" || lastVowelLetter == "i" || lastVowelLetter == "ö" || lastVowelLetter == "ü"){
stringSuffix = "le";
} else {
stringSuffix = "la";
}
break;
}
var result = string + apostrofMark + stringSuffix;
return result;
}