11// Configuración de idiomas
22const translations = {
3- es : {
3+ 'es-MX' : {
44 title : "Generador de Seriales Ultra Únicos" ,
5+ pageTitle : "Generador de Seriales Ultra Únicos" ,
56 segmentLength : "Tamaño de Segmentos:" ,
67 totalRandomLength : "Caracteres Aleatorios:" ,
78 prefix : "Prefijo (Opcional):" ,
@@ -23,8 +24,9 @@ const translations = {
2324 createdOn : "Serial creado el:" ,
2425 at : "a las"
2526 } ,
26- en : {
27+ 'en-US' : {
2728 title : "Ultra Unique Serial Generator" ,
29+ pageTitle : "Ultra Unique Serial Generator" ,
2830 segmentLength : "Segment Size:" ,
2931 totalRandomLength : "Random Characters:" ,
3032 prefix : "Prefix (Optional):" ,
@@ -49,7 +51,7 @@ const translations = {
4951} ;
5052
5153// Estado global de la aplicación
52- let currentLanguage = 'es ' ;
54+ let currentLanguage = 'en-US ' ;
5355let currentSerial = '' ;
5456let currentTab = 'generator' ;
5557
@@ -195,7 +197,7 @@ function formatDecodedDate(date, language = 'es') {
195197 timeZoneName : 'short'
196198 } ;
197199
198- const locale = language === 'es' ? 'es-ES ' : 'en-US' ;
200+ const locale = language === 'es-MX ' ? 'es-MX ' : 'en-US' ;
199201 return date . toLocaleDateString ( locale , options ) ;
200202}
201203
@@ -228,6 +230,14 @@ function handleDecodeSerial() {
228230// Función para cambiar el idioma
229231function changeLanguage ( lang ) {
230232 currentLanguage = lang ;
233+ const t = translations [ currentLanguage ] ;
234+
235+ // Actualizar título de la página
236+ document . title = t . pageTitle ;
237+
238+ // Actualizar atributo lang del HTML para SEO
239+ document . documentElement . lang = lang ;
240+
231241 updateUI ( ) ;
232242
233243 // Actualizar botones de idioma
@@ -261,7 +271,7 @@ function updateUI() {
261271 document . getElementById ( 'decodeButton' ) . textContent = t . decodeButton ;
262272
263273 // Actualizar placeholder del input de serial
264- document . getElementById ( 'serialInput' ) . placeholder = currentLanguage === 'es' ?
274+ document . getElementById ( 'serialInput' ) . placeholder = currentLanguage === 'es-MX ' ?
265275 'Ejemplo: PRODKEY-1ABCD23-EF45-GH67' :
266276 'Example: PRODKEY-1ABCD23-EF45-GH67' ;
267277
@@ -273,15 +283,15 @@ function updateUI() {
273283
274284 // Actualizar mensaje inicial si es necesario
275285 const serialOutput = document . getElementById ( 'serialOutput' ) ;
276- if ( serialOutput . textContent === translations . es . initialMessage ||
277- serialOutput . textContent === translations . en . initialMessage ) {
286+ if ( serialOutput . textContent === translations [ 'es-MX' ] . initialMessage ||
287+ serialOutput . textContent === translations [ 'en-US' ] . initialMessage ) {
278288 serialOutput . textContent = t . initialMessage ;
279289 }
280290
281291 // Actualizar mensaje inicial del decodificador si es necesario
282292 const dateOutput = document . getElementById ( 'dateOutput' ) ;
283- if ( dateOutput . textContent === translations . es . dateOutputInitial ||
284- dateOutput . textContent === translations . en . dateOutputInitial ) {
293+ if ( dateOutput . textContent === translations [ 'es-MX' ] . dateOutputInitial ||
294+ dateOutput . textContent === translations [ 'en-US' ] . dateOutputInitial ) {
285295 dateOutput . textContent = t . dateOutputInitial ;
286296 }
287297}
@@ -342,7 +352,7 @@ function copyToClipboard() {
342352// Inicialización cuando el DOM esté listo
343353document . addEventListener ( 'DOMContentLoaded' , ( ) => {
344354 // Cargar preferencias del localStorage
345- const savedLanguage = localStorage . getItem ( 'preferredLanguage' ) || 'es ' ;
355+ const savedLanguage = localStorage . getItem ( 'preferredLanguage' ) || 'en-US ' ;
346356 const savedTab = localStorage . getItem ( 'preferredTab' ) || 'generator' ;
347357 currentLanguage = savedLanguage ;
348358 currentTab = savedTab ;
0 commit comments