register update

This commit is contained in:
Samandar Turgunboyev
2026-03-18 17:56:26 +05:00
parent a34cf75c57
commit 22c1688781
31 changed files with 631 additions and 1080 deletions

55
constants/formatText.ts Normal file
View File

@@ -0,0 +1,55 @@
const latinToCyrillicMap = [
["O'", "Ў"], ["o'", "ў"],
["G'", "Ғ"], ["g'", "ғ"],
["Sh", "Ш"], ["sh", "ш"],
["Ch", "Ч"], ["ch", "ч"],
["A", "А"], ["B", "Б"], ["D", "Д"], ["E", "Е"], ["F", "Ф"],
["G", "Г"], ["H", "Ҳ"], ["I", "И"], ["J", "Ж"], ["K", "К"],
["L", "Л"], ["M", "М"], ["N", "Н"], ["O", "О"], ["P", "П"],
["Q", "Қ"], ["R", "Р"], ["S", "С"], ["T", "Т"], ["U", "У"],
["V", "В"], ["X", "Х"], ["Y", "Й"], ["Z", "З"],
["a", "а"], ["b", "б"], ["d", "д"], ["e", "е"], ["f", "ф"],
["g", "г"], ["h", "ҳ"], ["i", "и"], ["j", "ж"], ["k", "к"],
["l", "л"], ["m", "м"], ["n", "н"], ["o", "о"], ["p", "п"],
["q", "қ"], ["r", "р"], ["s", "с"], ["t", "т"], ["u", "у"],
["v", "в"], ["x", "х"], ["y", "й"], ["z", "з"],
["'", ""] // apostrofni olib tashlaymiz
];
export function formatText(str: string | null) {
if (!str) return null;
let result = str;
for (let [latin, cyrillic] of latinToCyrillicMap) {
const regex = new RegExp(latin, "g");
result = result.replace(regex, cyrillic);
}
return result;
}
const cyrillicToLatinMap = [
["Ў", "O'"], ["ў", "o'"],
["Ғ", "G'"], ["ғ", "g'"],
["Ш", "Sh"], ["ш", "sh"],
["Ч", "Ch"], ["ч", "ch"],
["ё", "yo"], ["Ё", "YO"],
["А", "A"], ["Б", "B"], ["Д", "D"], ["Е", "E"], ["Ф", "F"],
["Г", "G"], ["Ҳ", "H"], ["И", "I"], ["Ж", "J"], ["К", "K"],
["Л", "L"], ["М", "M"], ["Н", "N"], ["О", "O"], ["П", "P"],
["Қ", "Q"], ["Р", "R"], ["С", "S"], ["Т", "T"], ["У", "U"],
["В", "V"], ["Х", "X"], ["Й", "Y"], ["З", "Z"],
["а", "a"], ["б", "b"], ["д", "d"], ["е", "e"], ["ф", "f"],
["г", "g"], ["ҳ", "h"], ["и", "i"], ["ж", "j"], ["к", "k"],
["л", "l"], ["м", "m"], ["н", "n"], ["о", "o"], ["п", "p"],
["қ", "q"], ["р", "r"], ["с", "s"], ["т", "t"], ["у", "u"],
["в", "v"], ["х", "x"], ["й", "y"], ["з", "z"],
];
export function formatTextToLatin(str: string | null) {
if (!str) return null;
let result = str;
for (let [cyrillic, latin] of cyrillicToLatinMap) {
const regex = new RegExp(cyrillic, "g");
result = result.replace(regex, latin);
}
return result;
}