학생 회기 모바일 사용성 보정

This commit is contained in:
Yun Chan 2026-08-09 22:00:32 +09:00
parent aaebe4450e
commit c743e9ccb9
7 changed files with 395 additions and 31 deletions

View file

@ -11,6 +11,35 @@ const DISPLAY_PLACEHOLDERS: Record<string, string> = {
"[ADDRESS]": "주소",
};
function hasHangulBatchim(value: string) {
for (let index = value.length - 1; index >= 0; index -= 1) {
const code = value.charCodeAt(index);
if (code >= 0xac00 && code <= 0xd7a3) return (code - 0xac00) % 28 !== 0;
}
return false;
}
function replacePlaceholderWithNaturalParticle(
text: string,
placeholder: string,
label: string,
) {
const batchim = hasHangulBatchim(label);
let next = text;
for (const [variants, particle] of [
[["으로", "로"], batchim ? "으로" : "로"],
[["은", "는"], batchim ? "은" : "는"],
[["이", "가"], batchim ? "이" : "가"],
[["을", "를"], batchim ? "을" : "를"],
[["과", "와"], batchim ? "과" : "와"],
] as const) {
for (const variant of variants) {
next = next.split(`${placeholder}${variant}`).join(`${label}${particle}`);
}
}
return next.split(placeholder).join(label);
}
/**
* /API의 privacy-proof ,
* . · .
@ -24,7 +53,7 @@ export function displayPiiSafeText(text: string) {
"되는 건지 잘 모르겠는데요",
);
for (const [placeholder, label] of Object.entries(DISPLAY_PLACEHOLDERS)) {
next = next.split(placeholder).join(label);
next = replacePlaceholderWithNaturalParticle(next, placeholder, label);
}
return next;
}