로컬라이제이션 적용 (영어 / 한국어 )

This commit is contained in:
HyeongBaeYang committed 2026-02-10 14:39:58 +09:00
1 parent 29fdb7e65c
commit ad6f9e09a1
30 files changed
+1474 -309

No files matched your search

+56 -46
View File
@@ -1,5 +1,6 @@
import React, { useState, useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { generateLyric, waitForLyricComplete, generateSong, waitForSongComplete } from '../../utils/api';
import { LANGUAGE_MAP } from '../../types/api';
@@ -39,6 +40,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
videoGenerationStatus = 'idle',
videoGenerationProgress = 0
}) => {
const { t } = useTranslation();
const [selectedType, setSelectedType] = useState('보컬');
const [selectedLang, setSelectedLang] = useState('한국어');
const [selectedGenre, setSelectedGenre] = useState('자동 선택');
@@ -94,15 +96,15 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
songId,
(pollStatus: string) => {
if (pollStatus === 'streaming') {
setStatusMessage('노래를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingSong'));
} else if (pollStatus === 'queued') {
setStatusMessage('노래 생성 대기 중...');
setStatusMessage(t('soundStudio.songQueued'));
}
}
);
if (!statusResponse.success) {
throw new Error(statusResponse.error_message || '음악 생성에 실패했습니다.');
throw new Error(statusResponse.error_message || t('soundStudio.musicGenerationFailed'));
}
// song_result_url을 사용하여 재생
@@ -120,16 +122,16 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
if (currentRetryCount < MAX_RETRY_COUNT) {
const newRetryCount = currentRetryCount + 1;
setRetryCount(newRetryCount);
setStatusMessage(`시간 초과로 재생성 중... (${newRetryCount}/${MAX_RETRY_COUNT})`);
setStatusMessage(t('soundStudio.retryMessage', { count: newRetryCount, max: MAX_RETRY_COUNT }));
await regenerateSongOnly(currentLyrics, newRetryCount);
} else {
setStatus('error');
setErrorMessage('여러 번 시도했지만 음악 생성에 실패했습니다. 다시 시도해주세요.');
setErrorMessage(t('soundStudio.multipleRetryFailed'));
setRetryCount(0);
}
} else {
setStatus('error');
setErrorMessage(error instanceof Error ? error.message : '음악 생성 중 오류가 발생했습니다.');
setErrorMessage(error instanceof Error ? error.message : t('soundStudio.musicGenerationError'));
setRetryCount(0);
}
}
@@ -158,7 +160,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
});
if (!songResponse.success) {
throw new Error(songResponse.error_message || '음악 생성 요청에 실패했습니다.');
throw new Error(songResponse.error_message || t('soundStudio.songGenerationFailed'));
}
await resumePolling(songResponse.task_id, songResponse.song_id, currentLyrics, currentRetryCount);
@@ -166,7 +168,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
} catch (error) {
console.error('Song regeneration failed:', error);
setStatus('error');
setErrorMessage(error instanceof Error ? error.message : '음악 재생성 중 오류가 발생했습니다.');
setErrorMessage(error instanceof Error ? error.message : t('soundStudio.songRegenerationError'));
setRetryCount(0);
}
};
@@ -256,18 +258,18 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
const handleGenerateMusic = async () => {
if (!businessInfo) {
setErrorMessage('비즈니스 정보가 없습니다. 다시 시도해주세요.');
setErrorMessage(t('soundStudio.noBusinessInfo'));
return;
}
if (!imageTaskId) {
setErrorMessage('이미지 업로드 정보가 없습니다. 이전 단계로 돌아가 다시 시도해주세요.');
setErrorMessage(t('soundStudio.noImageUploadInfo'));
return;
}
setStatus('generating_lyric');
setErrorMessage(null);
setStatusMessage('가사를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingLyrics'));
try {
const language = LANGUAGE_MAP[selectedLang] || 'Korean';
@@ -282,33 +284,33 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
});
if (!lyricResponse.success || !lyricResponse.task_id) {
throw new Error(lyricResponse.error_message || '가사 생성 요청에 실패했습니다.');
throw new Error(lyricResponse.error_message || t('soundStudio.lyricGenerationFailed'));
}
// 2. 가사 생성 상태 폴링 → 완료 시 상세 조회
setStatusMessage('가사를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingLyrics'));
const lyricDetailResponse = await waitForLyricComplete(
lyricResponse.task_id,
(status: string) => {
if (status === 'processing') {
setStatusMessage('가사를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingLyrics'));
}
}
);
if (!lyricDetailResponse.lyric_result) {
throw new Error('가사를 받지 못했습니다.');
throw new Error(t('soundStudio.lyricNotReceived'));
}
// "I'm sorry" 체크
if (lyricDetailResponse.lyric_result.includes("I'm sorry")) {
throw new Error('가사 생성에 실패했습니다. 다시 시도해주세요.');
throw new Error(t('soundStudio.lyricGenerationError'));
}
setLyrics(lyricDetailResponse.lyric_result);
setStatus('generating_song');
setStatusMessage('노래를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingSong'));
const genreMap: Record<string, string> = {
'자동 선택': 'pop',
@@ -328,7 +330,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
});
if (!songResponse.success) {
throw new Error(songResponse.error_message || '음악 생성 요청에 실패했습니다.');
throw new Error(songResponse.error_message || t('soundStudio.songGenerationFailed'));
}
// 디버깅: songResponse 확인
@@ -337,18 +339,18 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
console.log('task_id:', songResponse.task_id);
if (!songResponse.song_id) {
throw new Error('서버에서 song_id를 받지 못했습니다.');
throw new Error(t('soundStudio.songIdMissing'));
}
setStatus('polling');
setStatusMessage('노래를 생성하고 있습니다...');
setStatusMessage(t('soundStudio.generatingSong'));
await resumePolling(songResponse.task_id, songResponse.song_id, lyricDetailResponse.lyric_result, 0);
} catch (error) {
console.error('Music generation failed:', error);
setStatus('error');
setErrorMessage(error instanceof Error ? error.message : '음악 생성 중 오류가 발생했습니다.');
setErrorMessage(error instanceof Error ? error.message : t('soundStudio.musicGenerationError'));
setRetryCount(0);
}
};
@@ -378,34 +380,38 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M15 18l-6-6 6-6" />
</svg>
뒤로가기
{t('soundStudio.back')}
</button>
</div>
{/* Page Title */}
<h1 className="sound-studio-title">사운드 스튜디오</h1>
<h1 className="sound-studio-title">{t('soundStudio.title')}</h1>
{/* Main Content - Two Column Layout */}
<div className="sound-studio-container">
<div className="sound-studio-columns">
{/* Left Column - Sound Settings */}
<div className="sound-column">
<h3 className="column-title">사운드</h3>
<h3 className="column-title">{t('soundStudio.soundColumn')}</h3>
{/* Sound Type Selection */}
<div className="sound-studio-section">
<label className="input-label">AI 사운드 유형 선택</label>
<label className="input-label">{t('soundStudio.soundTypeLabel')}</label>
<div className="sound-type-grid">
{['보컬', '배경음악', '성우 내레이션'].map(type => {
const isDisabled = type === '성우 내레이션' || isGenerating;
{[
{ key: '보컬', label: t('soundStudio.soundTypeVocal') },
{ key: '배경음악', label: t('soundStudio.soundTypeBGM') },
{ key: '성우 내레이션', label: t('soundStudio.soundTypeNarration') },
].map(({ key, label }) => {
const isDisabled = key === '성우 내레이션' || isGenerating;
return (
<button
key={type}
onClick={() => !isDisabled && setSelectedType(type)}
key={key}
onClick={() => !isDisabled && setSelectedType(key)}
disabled={isDisabled}
className={`sound-type-btn ${selectedType === type ? 'active' : ''} ${type === '성우 내레이션' ? 'permanently-disabled' : ''}`}
className={`sound-type-btn ${selectedType === key ? 'active' : ''} ${key === '성우 내레이션' ? 'permanently-disabled' : ''}`}
>
{type}
{label}
</button>
);
})}
@@ -414,17 +420,21 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
{/* Genre Selection */}
<div className="sound-studio-section">
<label className="input-label">장르 선택</label>
<label className="input-label">{t('soundStudio.genreLabel')}</label>
<div className="genre-grid">
<div className="genre-row">
{['자동 선택', 'K-POP', '발라드'].map(genre => (
{[
{ key: '자동 선택', label: t('soundStudio.genreAuto') },
{ key: 'K-POP', label: 'K-POP' },
{ key: '발라드', label: t('soundStudio.genreBallad') },
].map(({ key, label }) => (
<button
key={genre}
onClick={() => setSelectedGenre(genre)}
key={key}
onClick={() => setSelectedGenre(key)}
disabled={isGenerating}
className={`genre-btn ${selectedGenre === genre ? 'active' : ''}`}
className={`genre-btn ${selectedGenre === key ? 'active' : ''}`}
>
{genre}
{label}
</button>
))}
</div>
@@ -458,7 +468,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
{/* Language Selection */}
<div className="sound-studio-section">
<label className="input-label">언어</label>
<label className="input-label">{t('soundStudio.languageLabel')}</label>
<div className="language-selector-wrapper" ref={languageDropdownRef}>
<button
onClick={() => setIsLanguageDropdownOpen(!isLanguageDropdownOpen)}
@@ -499,8 +509,8 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
{/* Right Column - Lyrics */}
<div className="lyrics-column">
<div className="lyrics-header">
<h3 className="column-title">가사</h3>
<p className="lyrics-subtitle">가사 영역을 선택해서 수정 가능해요</p>
<h3 className="column-title">{t('soundStudio.lyricsColumn')}</h3>
<p className="lyrics-subtitle">{t('soundStudio.lyricsHint')}</p>
</div>
{/* Audio Player */}
@@ -545,11 +555,11 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
value={lyrics}
onChange={(e) => setLyrics(e.target.value)}
className="lyrics-textarea"
placeholder="사운드 생성 시 가사 표시됩니다."
placeholder={t('soundStudio.lyricsPlaceholder')}
/>
) : (
<div className="lyrics-placeholder">
사운드 생성 시 가사 표시됩니다.
{t('soundStudio.lyricsPlaceholder')}
</div>
)}
</div>
@@ -568,10 +578,10 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none"/>
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
</svg>
생성 중...
{t('soundStudio.generating')}
</>
) : (
'사운드 생성'
t('soundStudio.generateButton')
)}
</button>
@@ -607,7 +617,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
>
{videoGenerationStatus === 'generating' ? (
<>
<span className="video-gen-text">영상 생성 중</span>
<span className="video-gen-text">{t('soundStudio.videoGenerating')}</span>
<div className="video-gen-progress-bar">
<div
className="video-gen-progress-fill"
@@ -616,7 +626,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
</div>
</>
) : (
'영상 생성하기'
t('soundStudio.generateVideo')
)}
</button>
</div>