From: Lanius Trolling Date: Sun, 3 Sep 2023 12:15:47 +0000 (-0400) Subject: Add Pokhwalish language X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=17da8a27253bd5097fd2a7efce5077224f060733;p=factbooks Add Pokhwalish language --- diff --git a/src/main/kotlin/info/mechyrdia/Factbooks.kt b/src/main/kotlin/info/mechyrdia/Factbooks.kt index 867d0df..6d43060 100644 --- a/src/main/kotlin/info/mechyrdia/Factbooks.kt +++ b/src/main/kotlin/info/mechyrdia/Factbooks.kt @@ -223,6 +223,10 @@ fun Application.factbooks() { call.respondText(TylanAlphabet.tylanToFontAlphabet(call.receiveText())) } + post("/pokhwal-lang") { + call.respondText(PokhwalishAlphabet.pokhwalToFontAlphabet(call.receiveText())) + } + post("/preview-comment") { call.respondText( text = TextParserState.parseText(call.receiveText(), TextParserCommentTags.asTags, Unit), diff --git a/src/main/kotlin/info/mechyrdia/lore/languages.kt b/src/main/kotlin/info/mechyrdia/lore/languages.kt new file mode 100644 index 0000000..1e4d6a4 --- /dev/null +++ b/src/main/kotlin/info/mechyrdia/lore/languages.kt @@ -0,0 +1,127 @@ +package info.mechyrdia.lore + +object TylanAlphabet { + private val allowedTranslitCharacters = setOf( + ' ', '\r', '\n', '\t', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', + '[', '{', '}', ']', '\\', '|', '/', '<', + '.', ',', ':', ';', '\'', '"', '?', '>', + ) + + private val replacements = listOf( + Regex("([0-9xy]+)(?![\\s0-9xy])") to "$1 ", + Regex("(? + partial.replace(regex, replacement) + } +} + +object PokhwalishAlphabet { + private val allowedTranslitCharacters = setOf( + ' ', '\r', '\n', '\t', + 'a', 'b', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'y', 'z', + '.', ',', '\'', '?', '!', + ) + + private val replacements = listOf( + // Vowels + Regex("aa") to "A", + Regex("ae") to "A", + Regex("ee") to "E", + Regex("ei") to "E", + Regex("ey") to "E", + Regex("ie") to "I", + Regex("ii") to "I", + Regex("iy") to "I", + Regex("ao") to "O", + Regex("au") to "O", + Regex("oo") to "O", + Regex("ou") to "U", + Regex("uu") to "U", + // Consonants + Regex("tz") to "C", + Regex("hh") to "K", + Regex("kh") to "K", + Regex("gh") to "G", + Regex("ng(?![aeiouAEIOU])") to "N", + Regex("n'g") to "ng", + Regex("qh") to "Q", + Regex("th") to "T", + + Regex("ck") to "q", + Regex("k") to "q", + ) + + fun pokhwalToFontAlphabet(pokhwal: String) = replacements.fold(pokhwal.lowercase().filter { it in allowedTranslitCharacters }) { partial, (regex, replacement) -> + partial.replace(regex, replacement) + } +} diff --git a/src/main/kotlin/info/mechyrdia/lore/parser_tags.kt b/src/main/kotlin/info/mechyrdia/lore/parser_tags.kt index 7c37e5d..f56ccdf 100644 --- a/src/main/kotlin/info/mechyrdia/lore/parser_tags.kt +++ b/src/main/kotlin/info/mechyrdia/lore/parser_tags.kt @@ -294,7 +294,12 @@ enum class TextParserFormattingTag(val type: TextParserTagType) { "$recensored" } else if (tagParam?.equals("thedish", ignoreCase = true) == true) "$content" - else if (tagParam?.equals("gothic", ignoreCase = true) == true) + else if (tagParam?.equals("pokhval", ignoreCase = true) == true || tagParam?.equals("pokhwal", ignoreCase = true) == true) { + val uncensored = TextParserState.uncensorText(content) + val pokhwal = PokhwalishAlphabet.pokhwalToFontAlphabet(uncensored) + val recensored = TextParserState.censorText(pokhwal) + "$recensored" + } else if (tagParam?.equals("gothic", ignoreCase = true) == true) "$content" else content } @@ -319,7 +324,16 @@ enum class TextParserFormattingTag(val type: TextParserTagType) { | | """.trimMargin() - } else content + } else if (content.equals("pokhval", ignoreCase = true) || content.equals("pokhwal", ignoreCase = true)) { + """ + |
+ |

Latin Alphabet:

+ | + |

Pokhwalish Alphabet:

+ | + |
+ """.trimMargin() + } else "" } ), ; diff --git a/src/main/kotlin/info/mechyrdia/lore/tylan_language.kt b/src/main/kotlin/info/mechyrdia/lore/tylan_language.kt deleted file mode 100644 index f4d5395..0000000 --- a/src/main/kotlin/info/mechyrdia/lore/tylan_language.kt +++ /dev/null @@ -1,86 +0,0 @@ -package info.mechyrdia.lore - -object TylanAlphabet { - private val allowedTranslitCharacters = setOf( - ' ', '\r', '\n', '\t', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', - '[', '{', '}', ']', '\\', '|', '/', '<', - '.', ',', ':', ';', '\'', '"', '?', '>', - ) - - private val replacements = listOf( - Regex("([0-9xy]+)(?![\\s0-9xy])") to "$1 ", - Regex("(? - partial.replace(regex, replacement) - } -} diff --git a/src/main/resources/static/font/pokhval-alphabet.woff b/src/main/resources/static/font/pokhval-alphabet.woff new file mode 100644 index 0000000..2fa7d67 Binary files /dev/null and b/src/main/resources/static/font/pokhval-alphabet.woff differ diff --git a/src/main/resources/static/init.js b/src/main/resources/static/init.js index 5b733e6..4acac51 100644 --- a/src/main/resources/static/init.js +++ b/src/main/resources/static/init.js @@ -45,6 +45,31 @@ } }); + window.addEventListener("load", function () { + // Pokhwalish alphabet + async function pokhwalToFont(input, output) { + const inText = input.value; + const outText = await (await fetch('/pokhwal-lang', { + method: 'POST', + headers: { + 'Content-Type': 'text/plain', + }, + body: inText, + })).text(); + + if (inText === input.value) + output.value = outText; + } + + const pokhwalAlphabetBoxes = document.getElementsByClassName("pokhwal-alphabet-box"); + for (const pokhwalAlphabetBox of pokhwalAlphabetBoxes) { + const inputBox = pokhwalAlphabetBox.getElementsByClassName("input-box")[0]; + const outputBox = pokhwalAlphabetBox.getElementsByClassName("output-box")[0]; + + inputBox.addEventListener("input", () => pokhwalToFont(inputBox, outputBox)); + } + }); + window.addEventListener("load", function () { // Preview themes const themeChoices = document.getElementsByName("theme"); diff --git a/src/main/resources/static/style.css b/src/main/resources/static/style.css index 831710e..acf0aba 100644 --- a/src/main/resources/static/style.css +++ b/src/main/resources/static/style.css @@ -902,6 +902,24 @@ textarea.lang-thedish { line-height: 1.0; } +@font-face { + font-family: 'Pochvalsk'; + src: url(/static/font/pokhval-alphabet.woff) format('woff'); +} + +.lang-pokhwal { + font-family: Pochvalsk, monospace; + font-size: 1em; + line-height: 1.0; + font-variant: normal !important; +} + +textarea.lang-pokhwal { + font-family: Pochvalsk, monospace; + font-size: 2em; + line-height: 1.0; +} + #thumb-view { display: none; }