-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
クライアント側でNyaize処理を実行するようにした
- Loading branch information
Showing
14 changed files
with
314 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
modules/common_android/src/main/java/net/pantasystem/milktea/common_android/nyaize/Nyaize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.pantasystem.milktea.common_android.nyaize | ||
|
||
fun nyaize(text: String): String { | ||
// 日本語の変換 | ||
var result = text.replace("な", "にゃ").replace("ナ", "ニャ").replace("ナ", "ニャ") | ||
|
||
// 英語の変換 | ||
result = result.replace(Regex("(?<=n)a", RegexOption.IGNORE_CASE)) { | ||
if (it.value == "A") "YA" else "ya" | ||
} | ||
result = result.replace(Regex("(?<=morn)ing", RegexOption.IGNORE_CASE)) { | ||
if (it.value == "ING") "YAN" else "yan" | ||
} | ||
result = result.replace(Regex("(?<=every)one", RegexOption.IGNORE_CASE)) { | ||
if (it.value == "ONE") "NYAN" else "nyan" | ||
} | ||
|
||
// 韓国語の変換 | ||
result = result.replace(Regex("[나-낳]")) { | ||
val offset = '냐'.code - '나'.code | ||
it.value[0].plus(offset).toChar().toString() | ||
} | ||
result = result.replace(Regex("(다$)|(다(?=[.]))|(다(?= ))|(다(?=!))|(다(?=\\?))", RegexOption.MULTILINE)) { | ||
"다냥" | ||
} | ||
result = result.replace(Regex("(야(?=\\?))|(야$)|(야(?= ))", RegexOption.MULTILINE)) { | ||
"냥" | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.