import streamlit as st from transformers import pipeline def translate_text(text): model = pipeline("translation", model='Helsinki-NLP/opus-mt-ko-en') result = model(text) return result[0]['translation_text'] def main(): # 페이지 설정 st.set_page_config( page_title="한영 번역기", page_icon="🌏", layout="centered" ) # CSS 스타일 적용 st.markdown(""" """, unsafe_allow_html=True) # 헤더 st.markdown('

🌏 한글 → 영어 번역기

', unsafe_allow_html=True) # 설명 텍스트 st.markdown("#### 한국어를 영어로 번역해드립니다! 아래에 번역하고 싶은 텍스트를 입력해주세요. 😊") # 구분선 st.markdown("---") # 입력 컬럼과 결과 컬럼 생성 col1, col2 = st.columns([1, 1]) with col1: st.markdown("### 한국어 입력") user_input = st.text_area("", height=200, placeholder="번역할 한글을 입력하세요...") with col2: st.markdown("### 영어 번역") if user_input: translation = translate_text(user_input) st.markdown('
' + translation + '
', unsafe_allow_html=True) else: st.markdown('
번역 결과가 여기에 표시됩니다.
', unsafe_allow_html=True) # 번역 버튼 if st.button('번역하기 🔄'): if user_input: translation = translate_text(user_input) st.success('번역이 완료되었습니다! ✨') else: st.warning('⚠️ 텍스트를 입력해주세요.') # 푸터 st.markdown("---") st.markdown("##### Made with ❤️ using Streamlit") if __name__ == '__main__': main()