@@ -308,7 +308,7 @@ const PROFANITY_WORDS = [
308308/**
309309 * Validates a pseudo (username) and returns an error code or null if valid
310310 * @param {string } pseudo - The username to validate
311- * @returns {string|null } - Error code ('tooShort', 'tooLong', ' profanity') or null if valid
311+ * @returns {string|null } - Error code ('tooShort', 'profanity') or null if valid
312312 */
313313function validatePseudo ( pseudo ) {
314314 const trimmed = pseudo . trim ( ) ;
@@ -318,11 +318,6 @@ function validatePseudo(pseudo) {
318318 return 'tooShort' ;
319319 }
320320
321- // Check maximum length
322- if ( trimmed . length > PSEUDO_MAX_LENGTH ) {
323- return 'tooLong' ;
324- }
325-
326321 // Check for profanity - convert to lowercase for comparison
327322 const pseudoLower = trimmed . toLowerCase ( ) ;
328323
@@ -359,20 +354,16 @@ function validatePseudo(pseudo) {
359354}
360355
361356/**
362- * Gets the error message for a given error code
363- * @param {string } errorCode - The error code ('tooShort', 'tooLong', ' profanity')
364- * @returns {string } - The localized error message
357+ * Returns the translation key for a given error code
358+ * @param {string } errorCode - The error code ('tooShort', 'profanity')
359+ * @returns {string } - The translation key
365360 */
366361function getPseudoErrorMessage ( errorCode ) {
367- if ( ! errorCode ) return '' ;
368-
369362 switch ( errorCode ) {
370363 case 'tooShort' :
371- return i18next . t ( 'welcome.errorPseudoTooShort' , { min : PSEUDO_MIN_LENGTH } ) ;
372- case 'tooLong' :
373- return i18next . t ( 'welcome.errorPseudoTooLong' , { max : PSEUDO_MAX_LENGTH } ) ;
364+ return 'welcome.errorPseudoTooShort' ;
374365 case 'profanity' :
375- return i18next . t ( 'welcome.errorPseudoProfanity' ) ;
366+ return 'welcome.errorPseudoProfanity' ;
376367 default :
377368 return '' ;
378369 }
@@ -389,16 +380,13 @@ function displayPseudoError(errorCode, errorContainer) {
389380 if ( errorCode ) {
390381 const errorMessage = getPseudoErrorMessage ( errorCode ) ;
391382 errorContainer . innerHTML = `
392- <div class="alert alert-danger fade show mt-2" role="alert">
393- <span class="alert-icon" aria-hidden="true"></span>
394- <div class="alert-container">
395- <div class="alert-text-container">
396- <p class="alert-label m-0">${ errorMessage } </p>
397- </div>
398- </div>
383+ <div class="alert alert-danger alert-sm mt-2" role="alert">
384+ <span class="alert-icon"><span class="visually-hidden">Error</span></span>
385+ <p data-i18n="${ errorMessage } "></p>
399386 </div>
400387 ` ;
401388 errorContainer . classList . remove ( 'd-none' ) ;
389+ updateTranslations ( ) ;
402390 } else {
403391 errorContainer . innerHTML = '' ;
404392 errorContainer . classList . add ( 'd-none' ) ;
0 commit comments