-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 언어 설정 영어 추가 및 폴링 주기 5초로 변경 #29
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { createContext, type ReactNode, useContext } from "react"; | ||
|
|
||
| type Language = "ko" | "en"; | ||
|
|
||
| interface Translations { | ||
| ko: Record<string, string>; | ||
| en: Record<string, string>; | ||
| } | ||
|
|
||
| const translations: Translations = { | ||
| ko: { | ||
| // BusStops | ||
| "busStops.selectStop": "버스 정류장 선택하기", | ||
| "busStops.selectBus": "버스 선택하기", | ||
|
|
||
| // Bus Stop Names | ||
| "busStop.평화의광장": "평화의광장", | ||
| "busStop.치과병원": "치과병원", | ||
| "busStop.정문": "정문", | ||
| "busStop.죽전역": "죽전역", | ||
|
|
||
| // Directions | ||
| "direction.toDKU": "단국대학교 방향", | ||
| "direction.toJukjeon": "죽전역 방향", | ||
|
|
||
| // SettingsPanel | ||
| "settings.title": "설정", | ||
| "settings.language": "언어", | ||
| "settings.korean": "한국어", | ||
| "settings.english": "English", | ||
| "settings.contact": "문의하기", | ||
| "settings.userGuide": "사용 가이드", | ||
|
|
||
| // Common | ||
| "common.loading": "로딩 중...", | ||
| "common.error": "오류가 발생했습니다", | ||
| "common.noData": "데이터가 없습니다", | ||
| }, | ||
| en: { | ||
| // BusStops | ||
| "busStops.selectStop": "Select Bus Stop", | ||
| "busStops.selectBus": "Select Bus", | ||
|
|
||
| // Bus Stop Names | ||
| "busStop.평화의광장": "Dankook Univ. Peace Square", | ||
| "busStop.치과병원": "Dankook Univ. Dental Hospital", | ||
| "busStop.정문": "Dankook Univ. Main Gate", | ||
| "busStop.죽전역": "Jukjeon Stn/ Shinsegae S. City", | ||
|
|
||
| // Directions | ||
| "direction.toDKU": "→ Dankook Univ.", | ||
| "direction.toJukjeon": "→ Jukjeon Stn.", | ||
|
|
||
| // SettingsPanel | ||
| "settings.title": "Settings", | ||
| "settings.language": "Language", | ||
| "settings.korean": "한국어", | ||
| "settings.english": "English", | ||
| "settings.contact": "Contact Us", | ||
| "settings.userGuide": "User Guide", | ||
|
|
||
| // Common | ||
| "common.loading": "Loading...", | ||
| "common.error": "An error occurred", | ||
| "common.noData": "No data available", | ||
| }, | ||
| }; | ||
|
|
||
| interface LanguageContextType { | ||
| language: Language; | ||
| setLanguage: (lang: Language) => void; | ||
| t: (key: string) => string; | ||
| } | ||
|
|
||
| const LanguageContext = createContext<LanguageContextType | undefined>( | ||
| undefined | ||
| ); | ||
|
|
||
| interface LanguageProviderProps { | ||
| children: ReactNode; | ||
| language: Language; | ||
| setLanguage: (lang: Language) => void; | ||
| } | ||
|
|
||
| export function LanguageProvider({ | ||
| children, | ||
| language, | ||
| setLanguage, | ||
| }: LanguageProviderProps) { | ||
| const t = (key: string): string => { | ||
| return translations[language][key] || key; | ||
| }; | ||
|
|
||
| return ( | ||
| <LanguageContext.Provider value={{ language, setLanguage, t }}> | ||
| {children} | ||
| </LanguageContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export function useTranslation() { | ||
| const context = useContext(LanguageContext); | ||
| if (!context) { | ||
| throw new Error("useTranslation must be used within LanguageProvider"); | ||
| } | ||
| return context; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Language 타입을 export하여 공유하세요.
Language타입이 여러 파일에서 중복 정의되고 있습니다. 이 타입을 export하여 다른 파일에서 import하도록 하면 타입 일관성을 유지할 수 있습니다.다음과 같이 수정하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents