10000 [Feature]: josa에서 알파벳 한글 발음 처리 기능이 있었으면 합니다. · Issue #357 · toss/es-hangul · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature]: josa에서 알파벳 한글 발음 처리 기능이 있었으면 합니다. #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
D-Trick opened this issue May 28, 2025 · 1 comment

Comments

@D-Trick
Copy link
D-Trick commented May 28, 2025

Description

유효성 검사 에러 메시지 문구에 josa를 활용하다가 발견한 점이 있어 이렇게 이슈를 남겨봅니다.

josa에서 알파벳의 한글 발음 처리를 공식적으로 지원하면 좋을 것 같은데, 어떻게 생각하시나요?

현재는 임시로 직접 매핑하여 사용 중이지만, 공식적으로 지원된다면 좋을 것 같아 제안드립니다.

기존: URL를 입력해 주세요.
변경: URL을 입력해 주세요.

Possible Solution

제가 생각해본 것은 마지막 글자가 알파벳인지 검사한 뒤, 알파벳이라면 한글 발음 기준으로 조사를 처리하면 되지 않을까 합니다.

옵션으로 적용할 경우, 아래와 같은 방식으로 처리해볼 수 있을 것 같습니다.
josa('URL', '을/를', { allowAlphabets: true })

etc.

임시로 사용중인 코드 입니다. 참고만 해주세요.

import { josa as esJosa } from 'es-hangul';

function josa(text: string, josa: JosaOption) {
    const alphabetMap: Record<string, string> = {
        A: "에이",
        B: "비",
        C: "씨",
        D: "디",
        E: "이",
        F: "에프",
        G: "지",
        H: "에이치",
        I: "아이",
        J: "제이",
        K: "케이",
        L: "엘",
        M: "엠",
        N: "엔",
        O: "오",
        P: "피",
        Q: "큐",
        R: "알",
        S: "에스",
        T: "티",
        U: "유",
        V: "브이",
        W: "더블유",
        X: "엑스",
        Y: "와이",
        Z: "지",
    };

    const trimText = text.trim();
    const lastChar = trimText[text.length - 1].toUpperCase();
    const char = alphabetMap[lastChar];
    if (char) {
        return text + esJosa.pick(char, josa);
    }

    return esJosa(text, josa);
}
@grimza99
Copy link

살펴보니 구조상 영단어 약어만 가능할것 같습니다 josaPicker에서 단어가 모두 영단어 대문자일때 조건부 처리하고 인덱스를 결정해서 리턴하는식으로 해결 할것 같습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0