학생 회기 모바일 사용성 보정
This commit is contained in:
parent
aaebe4450e
commit
c743e9ccb9
7 changed files with 395 additions and 31 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue