File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use client'
22
33import { useState , useEffect } from 'react'
4+ import { useTranslations } from 'next-intl'
45import { cn } from '@/lib/utils'
56import { IconCopy , IconCheck , IconFile } from '@tabler/icons-react'
67
@@ -21,6 +22,7 @@ export function CodeBlock({
2122 highlightLines = [ ] ,
2223 className,
2324} : CodeBlockProps ) {
25+ const t = useTranslations ( 'components.codeBlock' )
2426 const [ copied , setCopied ] = useState ( false )
2527 const [ highlightedHtml , setHighlightedHtml ] = useState < string | null > ( null )
2628
@@ -90,24 +92,24 @@ export function CodeBlock({
9092 ) : language ? (
9193 < span className = "uppercase" > { language } </ span >
9294 ) : (
93- < span > Código </ span >
95+ < span > { t ( 'code' ) } </ span >
9496 ) }
9597 </ div >
9698 < button
9799 type = "button"
98100 onClick = { handleCopy }
99101 className = "flex items-center gap-1.5 rounded px-2 py-1 text-xs text-gray-400 hover:bg-gray-700 hover:text-gray-200 transition-colors"
100- aria-label = { copied ? 'Copiado' : 'Copiar código' }
102+ aria-label = { copied ? t ( 'copiedAriaLabel' ) : t ( 'copyAriaLabel' ) }
101103 >
102104 { copied ? (
103105 < >
104106 < IconCheck className = "size-4 text-green-400" />
105- < span > Copiado </ span >
107+ < span > { t ( 'copied' ) } </ span >
106108 </ >
107109 ) : (
108110 < >
109111 < IconCopy className = "size-4" />
110- < span > Copiar </ span >
112+ < span > { t ( 'copy' ) } </ span >
111113 </ >
112114 ) }
113115 </ button >
Original file line number Diff line number Diff line change 31203120 "finishCourse" : " Finish Course" ,
31213121 "completeFirst" : " Complete this lesson first"
31223122 },
3123+ "codeBlock" : {
3124+ "copy" : " Copy" ,
3125+ "copied" : " Copied" ,
3126+ "copyAriaLabel" : " Copy code" ,
3127+ "copiedAriaLabel" : " Copied" ,
3128+ "code" : " Code"
3129+ },
31233130 "lessonComments" : {
31243131 "title" : " Comments ({count})" ,
31253132 "placeholder" : " Share your thoughts or ask a question..." ,
Original file line number Diff line number Diff line change 29652965 "finishCourse" : " Finalizar Curso" ,
29662966 "completeFirst" : " Completa esta lección primero"
29672967 },
2968+ "codeBlock" : {
2969+ "copy" : " Copiar" ,
2970+ "copied" : " Copiado" ,
2971+ "copyAriaLabel" : " Copiar código" ,
2972+ "copiedAriaLabel" : " Copiado" ,
2973+ "code" : " Código"
2974+ },
29682975 "lessonComments" : {
29692976 "title" : " Comentarios ({count})" ,
29702977 "placeholder" : " Comparte tus pensamientos o haz una pregunta..." ,
You can’t perform that action at this time.
0 commit comments