kalpak-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +50 -0
  2. package/index.js +218 -0
  3. package/package.json +23 -0
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Kalpak.js 🧢
2
+
3
+ A lightweight, accurate JavaScript library for transliterating **Karakalpak** text between Latin and Cyrillic scripts.
4
+ Built by [**Ishipiskenler**](https://github.com/ishipiskenler) (The Doers).
5
+
6
+ > **Note:** This library follows the official Karakalpak alphabet tables (Yellow Table standards).
7
+
8
+ ## ✨ Features
9
+
10
+ - **Latin ➡️ Cyrillic**: Handles complex digraphs (Sh, Ch, etc.) correctly.
11
+ - **Cyrillic ➡️ Latin**: Supports official mappings (e.g., И→I, Ы→Í).
12
+ - **Zero Dependencies**: Pure JavaScript. Fast and simple.
13
+
14
+ ## 📦 Installation
15
+
16
+ ```bash
17
+ # Clone the repository
18
+ git clone https://github.com/ishipiskenler/karakalpak-translit-js.git
19
+ ```
20
+
21
+ _(NPM package coming soon!)_
22
+
23
+ ## 🚀 Usage
24
+
25
+ ```javascript
26
+ const { latinToCyrillic, cyrillicToLatin } = require("./index");
27
+
28
+ // 1. Latin to Cyrillic
29
+ const cyrillic = latinToCyrillic("Sálem, Qaraqalpaqstan!");
30
+ console.log(cyrillic);
31
+ // Output: "Сәлем, Қарақалпақстан!"
32
+
33
+ // 2. Cyrillic to Latin
34
+ const latin = cyrillicToLatin("Мен сeни жақсы көремен ❤️");
35
+ console.log(latin);
36
+ // Output: "Men seni jaqsı kóremen"
37
+ ```
38
+
39
+ ## 🤝 Contributing
40
+
41
+ We welcome contributions!
42
+
43
+ 1. Fork the repo
44
+ 2. Create your feature branch
45
+ 3. Commit your changes
46
+ 4. Open a Pull Request
47
+
48
+ ---
49
+
50
+ © 2026 **Ishipiskenler**. Open Source.
package/index.js ADDED
@@ -0,0 +1,218 @@
1
+ const latinToCyrillicMap = {
2
+ // Basic letters
3
+ A: "А",
4
+ a: "а",
5
+ B: "Б",
6
+ b: "б",
7
+ D: "Д",
8
+ d: "д",
9
+ E: "Е",
10
+ e: "е",
11
+ F: "Ф",
12
+ f: "ф",
13
+ G: "Г",
14
+ g: "г",
15
+ H: "Ҳ",
16
+ h: "ҳ",
17
+ X: "Х",
18
+ x: "х",
19
+ J: "Ж",
20
+ j: "ж",
21
+ K: "К",
22
+ k: "к",
23
+ Q: "Қ",
24
+ q: "қ",
25
+ L: "Л",
26
+ l: "л",
27
+ M: "М",
28
+ m: "м",
29
+ N: "Н",
30
+ n: "н",
31
+ O: "О",
32
+ o: "о",
33
+ P: "П",
34
+ p: "п",
35
+ R: "Р",
36
+ r: "р",
37
+ S: "С",
38
+ s: "с",
39
+ T: "Т",
40
+ t: "т",
41
+ U: "У",
42
+ u: "у",
43
+ V: "В",
44
+ v: "в",
45
+ Z: "З",
46
+ z: "з",
47
+
48
+ // Special Karakalpak letters
49
+ Á: "Ә",
50
+ á: "ә",
51
+ Ó: "Ө",
52
+ ó: "ө",
53
+ Ú: "Ү",
54
+ ú: "ү",
55
+ I: "И",
56
+ i: "и",
57
+ Í: "Ы",
58
+ ı: "ы",
59
+ Ǵ: "Ғ",
60
+ ǵ: "ғ",
61
+ Ń: "Ң",
62
+ ń: "ң",
63
+
64
+ // Extra letters
65
+ Y: "Й",
66
+ y: "й",
67
+ W: "Ў",
68
+ w: "ў",
69
+
70
+ // Digraphs
71
+ Sh: "Ш",
72
+ sh: "ш",
73
+ SH: "Ш",
74
+ Yu: "Ю",
75
+ yu: "ю",
76
+ Ya: "Я",
77
+ ya: "я",
78
+ Yo: "Ё",
79
+ yo: "ё",
80
+
81
+ Ch: "Ч",
82
+ ch: "ч",
83
+ CH: "Ч",
84
+
85
+ // Optional / borrowed letters
86
+ C: "Ц",
87
+ c: "ц",
88
+ };
89
+
90
+ const cyrillicToLatinMap = {
91
+ А: "A",
92
+ а: "a",
93
+ Ә: "Á",
94
+ ә: "á",
95
+ Б: "B",
96
+ б: "b",
97
+ В: "V",
98
+ в: "v",
99
+ Г: "G",
100
+ г: "g",
101
+ Ғ: "Ǵ",
102
+ ғ: "ǵ",
103
+ Д: "D",
104
+ д: "d",
105
+ Е: "E",
106
+ е: "e",
107
+ Ё: "Yo",
108
+ ё: "yo",
109
+ Ж: "J",
110
+ ж: "j",
111
+ З: "Z",
112
+ з: "z",
113
+ И: "I",
114
+ и: "i",
115
+ Й: "Y",
116
+ й: "y",
117
+ К: "K",
118
+ к: "k",
119
+ Қ: "Q",
120
+ қ: "q",
121
+ Л: "L",
122
+ л: "l",
123
+ М: "M",
124
+ м: "m",
125
+ Н: "N",
126
+ н: "n",
127
+ Ң: "Ń",
128
+ ң: "ń",
129
+ О: "O",
130
+ о: "o",
131
+ Ө: "Ó",
132
+ ө: "ó",
133
+ П: "P",
134
+ п: "p",
135
+ Р: "R",
136
+ р: "r",
137
+ С: "S",
138
+ с: "s",
139
+ Т: "T",
140
+ т: "t",
141
+ У: "U",
142
+ у: "u",
143
+ Ү: "Ú",
144
+ ү: "ú",
145
+ Ў: "W",
146
+ ў: "w",
147
+ Ф: "F",
148
+ ф: "f",
149
+ Х: "X",
150
+ х: "x",
151
+ Ҳ: "H",
152
+ ҳ: "h",
153
+ Ш: "Sh",
154
+ ш: "sh",
155
+ Ч: "Ch",
156
+ ч: "ch",
157
+ Щ: "Sh",
158
+ щ: "sh", // optional
159
+ Ы: "Í",
160
+ ы: "ı",
161
+
162
+ // Borrowed/Russian letters
163
+ Ц: "C",
164
+ ц: "c",
165
+ Э: "E",
166
+ э: "e",
167
+ Ю: "Yu",
168
+ ю: "yu",
169
+ Я: "Ya",
170
+ я: "ya",
171
+ Ъ: "",
172
+ ъ: "",
173
+ Ь: "",
174
+ ь: "",
175
+ };
176
+
177
+ function latinToCyrillic(text) {
178
+ let result = "";
179
+
180
+ for (let i = 0; i < text.length; i++) {
181
+ let twoChars = text[i] + (text[i + 1] || "");
182
+ if (latinToCyrillicMap[twoChars]) {
183
+ result += latinToCyrillicMap[twoChars];
184
+ i++;
185
+ continue;
186
+ }
187
+
188
+ let oneChar = text[i];
189
+ if (latinToCyrillicMap[oneChar]) {
190
+ result += latinToCyrillicMap[oneChar];
191
+ } else {
192
+ result += oneChar;
193
+ }
194
+ }
195
+
196
+ return result;
197
+ }
198
+
199
+ function cyrillicToLatin(text) {
200
+ let result = "";
201
+
202
+ for (let i = 0; i < text.length; i++) {
203
+ const char = text[i];
204
+
205
+ if (cyrillicToLatinMap[char] !== undefined) {
206
+ result += cyrillicToLatinMap[char];
207
+ } else {
208
+ result += char;
209
+ }
210
+ }
211
+
212
+ return result;
213
+ }
214
+
215
+ module.exports = {
216
+ latinToCyrillic,
217
+ cyrillicToLatin,
218
+ };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "kalpak-js",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "description": "A lightweight JavaScript library for Karakalpak Cyrillic-Latin transliteration.",
9
+ "keywords": [
10
+ "karakalpak",
11
+ "transliteration",
12
+ "cyrillic",
13
+ "latin",
14
+ "qaraqalpaq",
15
+ "language"
16
+ ],
17
+ "author": "Ishipiskenler",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/ishipiskenler/kalpak-js.git"
22
+ }
23
+ }