From 8e904a3a3c8dd05371858da80e5aaaeabe590b99 Mon Sep 17 00:00:00 2001 From: Hylston Barbosa Date: Fri, 18 Aug 2023 13:48:35 -0300 Subject: [PATCH] updates --- .../l10n/mojito/okapi/filters/JSONFilter.java | 39 +++++++++---------- .../box/l10n/mojito/okapi/XLIFFWriter.java | 6 +-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java index 0e9e43fe01..55233f7d4e 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java @@ -44,7 +44,7 @@ public class JSONFilter extends net.sf.okapi.filters.json.JSONFilter { */ boolean noteKeepOrReplace = false; - NoteAnnotation xliffNoteAnnotation; + NoteAnnotation noteAnnotation; UsagesAnnotation usagesAnnotation; String currentKeyName; String comment = null; @@ -144,17 +144,17 @@ void extractUsageIfMatch(String value) { } } - void addXliffNote(String value) { - Note xliffNote = new Note(value); - xliffNote.setFrom(currentKeyName); - xliffNote.setAnnotates(Note.Annotates.SOURCE); + void addNote(String value) { + Note note = new Note(value); + note.setFrom(currentKeyName); + note.setAnnotates(Note.Annotates.SOURCE); - if (xliffNoteAnnotation == null || noteKeepOrReplace) { - logger.debug("create the xliff note annotation"); - xliffNoteAnnotation = new NoteAnnotation(); + if (noteAnnotation == null || noteKeepOrReplace) { + logger.debug("create the note annotation"); + noteAnnotation = new NoteAnnotation(); } - xliffNoteAnnotation.add(xliffNote); + noteAnnotation.add(note); } void extractNoteIfMatch(String value) { @@ -163,7 +163,7 @@ void extractNoteIfMatch(String value) { if (m.matches()) { logger.debug("key matches noteKeyPattern, add the value as note"); - addXliffNote(value); + addNote(value); } } } @@ -172,10 +172,10 @@ void processComment() { if (comment != null) { ITextUnit textUnit = getEventTextUnit(); if (textUnit != null) { - String xliffNote = comment.replace("//", "").trim(); - addXliffNote(xliffNote); - textUnit.setAnnotation(xliffNoteAnnotation); - xliffNoteAnnotation = null; + String note = comment.replace("//", "").trim(); + addNote(note); + textUnit.setAnnotation(noteAnnotation); + noteAnnotation = null; } comment = null; } @@ -184,14 +184,14 @@ void processComment() { @Override public void handleObjectEnd() { - if (xliffNoteAnnotation != null || usagesAnnotation != null) { + if (noteAnnotation != null || usagesAnnotation != null) { ITextUnit textUnit = getEventTextUnit(); if (textUnit != null) { - if (xliffNoteAnnotation != null) { + if (noteAnnotation != null) { logger.debug("Set note on text unit with name: {}", textUnit.getName()); - textUnit.setAnnotation(xliffNoteAnnotation); + textUnit.setAnnotation(noteAnnotation); } if (usagesAnnotation != null) { @@ -203,10 +203,9 @@ public void handleObjectEnd() { } } - logger.debug( - "Reset the xliffNoteAnnotation and Usage Annotation if not using keepOrReplace option"); + logger.debug("Reset the noteAnnotation and Usage Annotation if not using keepOrReplace option"); if (!noteKeepOrReplace) { - xliffNoteAnnotation = null; + noteAnnotation = null; } if (!usagesKeepOrReplace) { diff --git a/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java b/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java index 1aebe969fd..8b57f70688 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java +++ b/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java @@ -603,12 +603,12 @@ public void writeTextUnit(ITextUnit tu, String phaseName) { // Notes if (tu.hasProperty(NoteAnnotation.LOC_NOTE)) { - writer.writeStartElement(NoteAnnotation.LOC_NOTE); + writer.writeStartElement("note"); writer.writeString(tu.getProperty(NoteAnnotation.LOC_NOTE).getValue()); writer.writeEndElementLineBreak(); // note } if (tu.hasProperty(NoteAnnotation.TRANS_NOTE)) { - writer.writeStartElement(NoteAnnotation.LOC_NOTE); + writer.writeStartElement("note"); writer.writeAttributeString("from", "translator"); writer.writeString(tu.getProperty(NoteAnnotation.TRANS_NOTE).getValue()); writer.writeEndElementLineBreak(); // note @@ -619,7 +619,7 @@ public void writeTextUnit(ITextUnit tu, String phaseName) { if (annotation != null) { Note note = annotation.getNote(0); - writer.writeStartElement(NoteAnnotation.LOC_NOTE); + writer.writeStartElement("note"); writer.writeString(note.getNoteText()); writer.writeEndElementLineBreak(); }