@@ -17,16 +17,23 @@ export function updateOcrSuggestions(ocrMatch, suggestions) {
1717
1818 // Display the parsed OCR value
1919 const parsedValue = ocrMatch . parsed_value ;
20- const fieldType = ocrMatch . field_type === "id_number" ? "ID Number" : "Username" ;
20+ const fieldType =
21+ ocrMatch . field_type === "id_number"
22+ ? I18n . t ( "activerecord.attributes.user.id_number" )
23+ : I18n . t ( "activerecord.attributes.user.user_name" ) ;
2124 const ocrDisplay = $ ( "<p></p>" ) ;
22- ocrDisplay . append ( `<strong>OCR Detected ${ fieldType } :</strong> ` ) ;
25+ ocrDisplay . append (
26+ `<strong>${ I18n . t ( "exam_templates.assign_scans.ocr_detected" , { field_type : fieldType } ) } </strong> `
27+ ) ;
2328 const codeElem = $ ( "<code></code>" ) . text ( parsedValue ) ;
2429 ocrDisplay . append ( codeElem ) ;
2530 container . append ( ocrDisplay ) ;
2631
2732 // Display suggestions if available
2833 if ( suggestions && suggestions . length > 0 ) {
29- container . append ( "<p><strong>Suggested Students:</strong></p>" ) ;
34+ container . append (
35+ `<p><strong>${ I18n . t ( "exam_templates.assign_scans.suggested_students" ) } </strong></p>`
36+ ) ;
3037 const list = $ ( '<ul class="ui-menu ocr-suggestions-list"></ul>' ) ;
3138
3239 suggestions . forEach ( function ( suggestion ) {
@@ -36,7 +43,9 @@ export function updateOcrSuggestions(ocrMatch, suggestions) {
3643
3744 // Use .text() to safely insert user-supplied data and prevent XSS
3845 const nameElem = $ ( "<strong></strong>" ) . text ( suggestion . display_name ) ;
39- const infoText = `${ suggestion . id_number || "No ID" } | ${ suggestion . user_name } ` ;
46+ const infoText = `${ suggestion . id_number || I18n . t ( "exam_templates.assign_scans.no_id" ) } | ${
47+ suggestion . user_name
48+ } `;
4049 const infoElem = $ ( '<span class="student-info"></span>' ) . text ( infoText ) ;
4150
4251 content . append ( nameElem ) ;
@@ -56,6 +65,8 @@ export function updateOcrSuggestions(ocrMatch, suggestions) {
5665
5766 container . append ( list ) ;
5867 } else if ( ! ocrMatch . matched ) {
59- container . append ( '<p class="no-match">No similar students found. Please assign manually.</p>' ) ;
68+ container . append (
69+ `<p class="no-match">${ I18n . t ( "exam_templates.assign_scans.no_similar_students" ) } </p>`
70+ ) ;
6071 }
6172}
0 commit comments