개발/🟦 React
다국어 처리 useTranslation() 훅 사용
비니_
2025. 12. 3. 14:23
728x90
import { useTranslation } from 'react-i18next';
import { useCallback } from 'react';
const Profile () => {
const { t } = useTranslation();
const tr = useCallback((name) => t(`userDashboard.${name}`), [t]);
}
const translation = useTranslation();
const t = translation.t;
이걸 짧게 구조 분해 할당한 것이 아래처러 쓰는 것 (실무에서는 보통 이렇게 씀)
const { t } = useTranslation();
저렇게 하고 각 언어 폴더에 있는 userDashboard.json 안에 각 폴더에 맞는 언어를 적어주기
728x90