mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-08 15:00:37 -04:00
(hbs) poc transliteration
This commit is contained in:
parent
595c0e6222
commit
cde7eef6bb
@ -13,6 +13,7 @@ const store = useMainStore();
|
||||
const spellings: Record<string, Record<string, string>> = {
|
||||
zh: { traditional: '繁體', simplified: '简体' },
|
||||
tok: { latin: 'sitelen Lasina', sitelen: 'sitelen\xa0pona' },
|
||||
hbs: { latin: 'latinica', cyrillic: 'ћирилица' },
|
||||
};
|
||||
|
||||
const spellingCookie = useCookie('spelling', longtimeCookieSetting);
|
||||
|
@ -14,6 +14,98 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move to a separate file
|
||||
const HBS_LATIN_TO_CYRILLIC: Record<string, string> = {
|
||||
'A': 'А',
|
||||
'a': 'а',
|
||||
'B': 'Б',
|
||||
'b': 'б',
|
||||
'C': 'Ц',
|
||||
'c': 'ц',
|
||||
'Č': 'Ч',
|
||||
'č': 'ч',
|
||||
'Ć': 'Ћ',
|
||||
'ć': 'ћ',
|
||||
'D': 'Д',
|
||||
'd': 'д',
|
||||
'Dž': 'Џ',
|
||||
'dž': 'џ',
|
||||
'Đ': 'Ђ',
|
||||
'đ': 'ђ',
|
||||
'E': 'Е',
|
||||
'e': 'е',
|
||||
'F': 'Ф',
|
||||
'f': 'ф',
|
||||
'G': 'Г',
|
||||
'g': 'г',
|
||||
'H': 'Х',
|
||||
'h': 'х',
|
||||
'I': 'И',
|
||||
'i': 'и',
|
||||
'J': 'Ј',
|
||||
'j': 'ј',
|
||||
'K': 'К',
|
||||
'k': 'к',
|
||||
'L': 'Л',
|
||||
'l': 'л',
|
||||
'Lj': 'Љ',
|
||||
'lj': 'љ',
|
||||
'M': 'М',
|
||||
'm': 'м',
|
||||
'N': 'Н',
|
||||
'n': 'н',
|
||||
'Nj': 'Њ',
|
||||
'nj': 'њ',
|
||||
'O': 'О',
|
||||
'o': 'о',
|
||||
'P': 'П',
|
||||
'p': 'п',
|
||||
'R': 'Р',
|
||||
'r': 'р',
|
||||
'S': 'С',
|
||||
's': 'с',
|
||||
'Š': 'Ш',
|
||||
'š': 'ш',
|
||||
'T': 'Т',
|
||||
't': 'т',
|
||||
'U': 'У',
|
||||
'u': 'у',
|
||||
'V': 'В',
|
||||
'v': 'в',
|
||||
'Z': 'З',
|
||||
'z': 'з',
|
||||
'Ž': 'Ж',
|
||||
'ž': 'ж',
|
||||
}
|
||||
|
||||
const hbsLatinToCyrillic = (str: string): string => {
|
||||
let result = '';
|
||||
let i = 0;
|
||||
|
||||
while (i < str.length) {
|
||||
if (i + 1 < str.length) {
|
||||
// check for digraphs
|
||||
const digraph = str.substring(i, i + 2);
|
||||
if (HBS_LATIN_TO_CYRILLIC.hasOwnProperty(digraph)) {
|
||||
result += HBS_LATIN_TO_CYRILLIC[digraph];
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const char = str[i];
|
||||
if (HBS_LATIN_TO_CYRILLIC.hasOwnProperty(char)) {
|
||||
result += HBS_LATIN_TO_CYRILLIC[char];
|
||||
} else {
|
||||
result += char;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const config = useConfig();
|
||||
const store = useMainStore();
|
||||
@ -50,6 +142,10 @@ export default () => {
|
||||
return `<span class="sitelen">${str}</span>`;
|
||||
}
|
||||
|
||||
if (config.locale === 'hbs' && store.spelling === 'cyrillic') {
|
||||
return hbsLatinToCyrillic(str);
|
||||
}
|
||||
|
||||
return str;
|
||||
},
|
||||
convertName(name: string): string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user