Skip to content

Commit 91a1205

Browse files
committed
ISSUE-7449: Internationalize strings
1 parent cf159aa commit 91a1205

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

app/javascript/common/ocr_suggestions.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

config/locales/views/exam_templates/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ en:
1717
done: All groups have been successfully assigned students
1818
help: Assign students to scanned exam groups based on printed student names.
1919
no_cover_page: This submission does not have a cover page.
20+
no_id: No ID
21+
no_similar_students: No similar students found. Please assign manually.
2022
not_all_submissions_collected: Not all submissions have been collected.
23+
ocr_detected: 'OCR Detected %{field_type}:'
2124
skip_group: Skip group
2225
student_not_found: Student with name %{name} does not exist.
26+
suggested_students: 'Suggested Students:'
2327
title: Assign Scans
2428
back_to_exam_templates_page: Back to Exam Templates page
2529
create:

0 commit comments

Comments
 (0)