[PR #2541] [MERGED] fix(game): match non-Latin speaker names for avatars and sprites #5644

Closed
opened 2026-10-22 04:18:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2541
Author: @Lemon-will
Created: 6/9/2026
Status: ✅ Merged
Merged: 6/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/game-character-name-match-cjk


📝 Commits (1)

  • 81398ab fix(game): match non-Latin speaker names for avatars and sprites

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 packages/client/src/lib/game-character-name-match.ts (+5 -1)

📄 Description

Linked issue

Closes #2534

Why this change

In Game Mode, characters whose names are written in non-Latin scripts (Japanese
hiragana/katakana/kanji, Cyrillic, etc.) never showed their message-window avatar
or full-body character sprite — the avatar fell back to the default silhouette.
The same character's round icon rendered correctly, which pointed at speaker-name
matching rather than asset loading.

Root cause: normalizeCharacterName
(packages/client/src/lib/game-character-name-match.ts) normalized with
[^a-z0-9], stripping every non-Latin character. Non-Latin names collapsed to an
empty string, so findNamedEntry bailed out early and
findNamedMapValue(speakerAvatarInfos, speaker) never matched. That single
failure caused both symptoms: the silhouette avatar fallback, and an unset
activeSpeaker that blocked full-body sprite resolution.

What changed

  • normalizeCharacterName: replaced ASCII-only [^a-z0-9]+ with
    [^\p{L}\p{N}\p{M}]+ and the u flag, keeping letters/numbers/combining marks
    from any script (the combining-mark class preserves e.g. the katakana
    voiced-sound mark). ASCII/Latin names normalize exactly as before — a one-line
    behavioral change.

Out of scope (follow-up): fuzzy/partial matching is still tuned for Latin —
getCharacterNameTokens drops tokens of length ≤ 2 and includesWholeVariant
requires length ≥ 3, so short CJK names (e.g. a 2-char name with a decorated
speaker label like ナミ(怒)) may still miss exact match. Left for a separate
PR to keep this focused.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Tested on a local production build:

  • pnpm check (impeccable check + lint + typecheck + production build) — passed.
  • Game Mode, katakana-named character (カエデ): message-window avatar now shows the character image instead of npc-silhouette.
  • Game Mode, hiragana-named character (かえで): same result.
  • Game Mode: the character's full-body sprite renders when a full_* sprite exists.
  • ASCII/Latin-named character (like kaede): avatar + sprite still resolve as before (no regression).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2541 **Author:** [@Lemon-will](https://github.com/Lemon-will) **Created:** 6/9/2026 **Status:** ✅ Merged **Merged:** 6/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/game-character-name-match-cjk` --- ### 📝 Commits (1) - [`81398ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/81398abcf90154206ec27808dacdb1265b34d49b) fix(game): match non-Latin speaker names for avatars and sprites ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/lib/game-character-name-match.ts` (+5 -1) </details> ### 📄 Description ## Linked issue Closes #2534 ## Why this change In Game Mode, characters whose names are written in non-Latin scripts (Japanese hiragana/katakana/kanji, Cyrillic, etc.) never showed their message-window avatar or full-body character sprite — the avatar fell back to the default silhouette. The same character's round icon rendered correctly, which pointed at speaker-name matching rather than asset loading. Root cause: `normalizeCharacterName` (`packages/client/src/lib/game-character-name-match.ts`) normalized with `[^a-z0-9]`, stripping every non-Latin character. Non-Latin names collapsed to an empty string, so `findNamedEntry` bailed out early and `findNamedMapValue(speakerAvatarInfos, speaker)` never matched. That single failure caused both symptoms: the silhouette avatar fallback, and an unset `activeSpeaker` that blocked full-body sprite resolution. ## What changed - `normalizeCharacterName`: replaced ASCII-only `[^a-z0-9]+` with `[^\p{L}\p{N}\p{M}]+` and the `u` flag, keeping letters/numbers/combining marks from any script (the combining-mark class preserves e.g. the katakana voiced-sound mark). ASCII/Latin names normalize exactly as before — a one-line behavioral change. Out of scope (follow-up): fuzzy/partial matching is still tuned for Latin — `getCharacterNameTokens` drops tokens of length ≤ 2 and `includesWholeVariant` requires length ≥ 3, so short CJK names (e.g. a 2-char name with a decorated speaker label like `ナミ(怒)`) may still miss exact match. Left for a separate PR to keep this focused. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Tested on a local production build: - `pnpm check` (impeccable check + lint + typecheck + production build) — passed. - Game Mode, katakana-named character (`カエデ`): message-window avatar now shows the character image instead of `npc-silhouette`. - Game Mode, hiragana-named character (`かえで`): same result. - Game Mode: the character's full-body sprite renders when a `full_*` sprite exists. - ASCII/Latin-named character (like `kaede`): avatar + sprite still resolve as before (no regression). ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:05 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5644
No description provided.