11import { useState , useMemo , useCallback } from 'react'
22import { Plus , Minus , Play , RotateCcw , Users , AlertTriangle } from 'lucide-react'
33import { useI18n } from '../i18n'
4+ import { useGameText } from '../hooks/useGameText'
45import { useTimer } from '../hooks/useTimer'
56import { aliasWords , aliasWordsEn } from '../data/words'
67import clsx from 'clsx'
@@ -15,6 +16,7 @@ interface Team {
1516export default function AliasGame ( ) {
1617 const { t, lang } = useI18n ( )
1718 const L = ( ru : string , en : string ) => lang === 'ru' ? ru : en
19+ const G = useGameText ( )
1820
1921 const [ phase , setPhase ] = useState < Phase > ( 'setup' )
2022 const [ teams , setTeams ] = useState < Team [ ] > ( [
@@ -142,7 +144,7 @@ export default function AliasGame() {
142144 < h2 className = "text-2xl font-bold" > { L ( 'Алиас' , 'Alias' ) } </ h2 >
143145
144146 < div className = "card p-4 text-sm text-text-secondary space-y-1" >
145- < p className = "font-medium text-text mb-2" > { L ( 'Как играть:' , 'How to play: ') } </ p >
147+ < p className = "font-medium text-text mb-2" > { G ( 'how_to_play ') } </ p >
146148 < p > 1. { L ( 'Разделитесь на команды' , 'Split into teams' ) } </ p >
147149 < p > 2. { L ( 'Один объясняет слово — остальные угадывают' , 'One explains — others guess' ) } </ p >
148150 < p > 3. { L ( 'Нельзя: однокоренные слова, жесты, звуки' , 'No root words, gestures, or sounds' ) } </ p >
@@ -154,10 +156,7 @@ export default function AliasGame() {
154156 < div className = "card p-3 border-amber-500/30 bg-amber-500/5 flex items-start gap-2 text-sm" >
155157 < AlertTriangle size = { 18 } className = "text-amber-400 shrink-0 mt-0.5" />
156158 < p className = "text-amber-300" >
157- { L (
158- 'Рекомендуется минимум 4 игрока (по 2 в команде). Сейчас: ' + totalPlayers ,
159- 'At least 4 players recommended (2 per team). Currently: ' + totalPlayers
160- ) }
159+ { G ( 'min_players_warning' ) } ({ L ( 'по 2 в команде' , '2 per team' ) } ). { L ( 'Сейчас' , 'Currently' ) } : { totalPlayers }
161160 </ p >
162161 </ div >
163162 ) }
@@ -186,7 +185,7 @@ export default function AliasGame() {
186185 { /* Players per team */ }
187186 < div className = "flex items-center gap-2 ml-1 text-xs text-text-muted" >
188187 < Users size = { 12 } />
189- < span > { L ( 'Игроков:' , 'Players: ') } </ span >
188+ < span > { G ( 'players_label ') } </ span >
190189 < button onClick = { ( ) => updatePlayersPerTeam ( i , - 1 ) }
191190 className = "w-5 h-5 rounded bg-bg-surface flex items-center justify-center hover:bg-border transition-colors" >
192191 < Minus size = { 10 } />
@@ -202,19 +201,19 @@ export default function AliasGame() {
202201 { /* Total players */ }
203202 < div className = "flex items-center justify-end gap-1.5 text-xs text-text-muted pt-1" >
204203 < Users size = { 12 } />
205- < span > { L ( 'Всего игроков:' , 'Total players: ') } < span className = "font-mono text-text" > { totalPlayers } </ span > </ span >
204+ < span > { G ( 'total_players ') } < span className = "font-mono text-text" > { totalPlayers } </ span > </ span >
206205 </ div >
207206 </ div >
208207
209208 { /* Recommended settings */ }
210209 < div className = "card p-3 bg-accent/5 border-accent/20 space-y-1.5 text-sm" >
211210 < p className = "font-medium text-accent text-xs uppercase tracking-wider" >
212- { L ( 'Рекомендуемые настройки' , 'Recommended settings ') }
211+ { G ( 'recommended_settings ') }
213212 </ p >
214213 < p className = "text-text-secondary" >
215- { L ( 'Цель' , 'Target ') } : < span className = "text-text font-mono" > { suggestTargetScore ( teams . length ) } </ span > { t . game . points }
214+ { G ( 'target ') } : < span className = "text-text font-mono" > { suggestTargetScore ( teams . length ) } </ span > { t . game . points }
216215 { ' · ' }
217- { L ( 'Таймер' , 'Timer' ) } : < span className = "text-text font-mono" > { getRecommendedTimer ( ) } </ span > { L ( 'сек' , 'sec' ) }
216+ { L ( 'Таймер' , 'Timer' ) } : < span className = "text-text font-mono" > { getRecommendedTimer ( ) } </ span > { G ( 'sec' ) }
218217 </ p >
219218 < p className = "text-text-muted text-xs" >
220219 { L (
@@ -228,15 +227,15 @@ export default function AliasGame() {
228227 < div className = "card p-4 space-y-4" >
229228 < div >
230229 < label className = "text-sm text-text-secondary block mb-2" >
231- { L ( 'Цель' , 'Target score ') } : < span className = "text-text font-mono" > { targetScore } </ span > { t . game . points }
230+ { G ( 'target_score ') } : < span className = "text-text font-mono" > { targetScore } </ span > { t . game . points }
232231 </ label >
233232 < input type = "range" min = { 20 } max = { 100 } step = { 10 } value = { targetScore }
234233 onChange = { e => setTargetScore ( Number ( e . target . value ) ) }
235234 className = "w-full accent-accent" />
236235 </ div >
237236 < div >
238237 < label className = "text-sm text-text-secondary block mb-2" >
239- { L ( 'Время на ход' , 'Turn time' ) } : < span className = "text-text font-mono" > { timerSeconds } </ span > { L ( 'сек' , 'sec' ) }
238+ { G ( 'turn_time' ) } : < span className = "text-text font-mono" > { timerSeconds } </ span > { G ( 'sec' ) }
240239 </ label >
241240 < input type = "range" min = { 30 } max = { 120 } step = { 10 } value = { timerSeconds }
242241 onChange = { e => setTimerSeconds ( Number ( e . target . value ) ) }
@@ -276,25 +275,22 @@ export default function AliasGame() {
276275 ) }
277276
278277 < div className = "card p-8 space-y-4" >
279- < p className = "text-text-muted text-sm" > { L ( 'Ход команды' , 'Current turn ') } </ p >
278+ < p className = "text-text-muted text-sm" > { G ( 'current_turn ') } </ p >
280279 < p className = "text-3xl font-bold text-accent" > { teams [ currentTeam ] . name } </ p >
281280 < p className = "text-text-secondary text-sm" >
282- { L (
283- 'Передайте телефон объясняющему игроку. У вас ' + timerSeconds + ' секунд.' ,
284- 'Pass the phone to the explainer. You have ' + timerSeconds + ' seconds.'
285- ) }
281+ { G ( 'pass_phone' ) } . { L ( 'У вас ' + timerSeconds + ' секунд.' , 'You have ' + timerSeconds + ' seconds.' ) }
286282 </ p >
287283 </ div >
288284
289285 < div className = "card p-4 text-sm text-text-muted space-y-1" >
290- < p > { L ( 'Напоминание:' , 'Reminder: ') } </ p >
291- < p > • { L ( 'Нельзя использовать однокоренные слова' , 'No root words allowed ') } </ p >
292- < p > • { L ( 'Нельзя показывать жестами' , 'No gestures allowed ') } </ p >
293- < p > • { L ( 'Если сложно — лучше пропустить' , 'If it\'s hard — better skip ') } </ p >
286+ < p > { G ( 'reminder ') } </ p >
287+ < p > • { G ( 'no_root_words ') } </ p >
288+ < p > • { G ( 'no_gestures ') } </ p >
289+ < p > • { G ( 'better_skip ') } </ p >
294290 </ div >
295291
296292 < button onClick = { startTurn } className = "btn-primary w-full text-lg py-4" >
297- < Play size = { 20 } /> { L ( 'Старт!' , 'Start! ') }
293+ < Play size = { 20 } /> { G ( 'start_btn ') }
298294 </ button >
299295 </ div >
300296 )
@@ -370,7 +366,7 @@ export default function AliasGame() {
370366 { turnScore >= 0 ? `+${ turnScore } ` : turnScore }
371367 </ p >
372368 < p className = "text-text-muted text-sm mt-2" >
373- { L ( 'Всего' , 'Total ') } : { teams [ currentTeam ] . score } /{ targetScore }
369+ { G ( 'total ') } : { teams [ currentTeam ] . score } /{ targetScore }
374370 </ p >
375371 </ div >
376372
@@ -392,8 +388,8 @@ export default function AliasGame() {
392388
393389 < button onClick = { nextTurn } className = "btn-primary w-full" >
394390 { teams . some ( t => t . score >= targetScore )
395- ? L ( 'Результаты' , 'Results ')
396- : L ( 'Ход следующей команды' , 'Next team\'s turn ') }
391+ ? G ( 'results ')
392+ : G ( 'next_teams_turn ') }
397393 </ button >
398394 </ div >
399395 )
0 commit comments