Skip to content

Conversation

@eveveev
Copy link

@eveveev eveveev commented May 31, 2025

신경써서 구현한 부분

LanguageProvider.jsx

  const changeLanguage = () => {
    setLanguage((prev) => (prev === "eng" ? "kor" : "eng"));
  };

버튼을 누를 때 마다 한글과 영어를 전환할 수 있게 했습니다.


Navbar.jsx

  const { language, changeLanguage } = useContext(LanguageContext);

  const text = {
    kor: {
      home: "홈",
      projects: "프로젝트",
      about: "자기소개",
    },
    eng: {
      home: "Home",
      projects: "Projects",
      about: "About",
    },
  };

  const lan = text[language];

language 값이 "kor"이면 한국어, "eng"면 영어가 나오도록 했습니다.

구현 화면

스크린샷 2025-05-31 133622
스크린샷 2025-05-31 133614


스크린샷 2025-05-31 140127
스크린샷 2025-05-31 140134

Comment on lines +4 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changeLanguage를 통해 상태를 관리하는 방법이 직관적이라 좋네요!

Comment on lines +8 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상태에 따른 내비게이션 바를 한글, 영어로 출력되도록 text를 선언하는 방식도 좋은 방법입니다!

Comment on lines +7 to +20
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const lan = text[language];를 통해 언어에 따른 텍스트 선택을 간결하게 잘 구현하셨습니다.

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

Successfully merging this pull request may close these issues.

4 participants