diff --git a/src/org/omegat/Bundle.properties b/src/org/omegat/Bundle.properties index 19327348bb..ef891b5b95 100644 --- a/src/org/omegat/Bundle.properties +++ b/src/org/omegat/Bundle.properties @@ -2129,6 +2129,13 @@ MATCHES_THIS_PROJECT=This project # 0 Number of additional matches. There is a non-break space between {0} and more MATCHES_MULTI_FILE_HINT=(+{0}\u00A0more) +MATCHES_SUBSEGMENTS_HINT=(+subsegments) + +MATCHES_COMES_FROM_TM=External TM +MATCHES_COMES_FROM_FILES=Source Files +MATCHES_COMES_FROM_MEMORY=Project +MATCHES_COMES_FROM_SUBSEGMENTS=Sub-segmented match + MATCHES_OPEN_PREFERENCES=TM Matching Options # Dictionary area popup menu diff --git a/src/org/omegat/Bundle_fr.properties b/src/org/omegat/Bundle_fr.properties index 996f961a98..d01135fbaa 100644 --- a/src/org/omegat/Bundle_fr.properties +++ b/src/org/omegat/Bundle_fr.properties @@ -1965,6 +1965,8 @@ MATCHES_THIS_PROJECT=Ce projet # 0 Number of additional matches. There is a non-break space between {0} and more MATCHES_MULTI_FILE_HINT=({0}\u00A0de\u00A0plus) +MATCHES_SUBSEGMENTS_HINT=(+sous-segments) + MATCHES_OPEN_PREFERENCES=Options des correspondances # Dictionary area popup menu diff --git a/src/org/omegat/core/matching/NearString.java b/src/org/omegat/core/matching/NearString.java index 651f63e1e5..b199cc8016 100644 --- a/src/org/omegat/core/matching/NearString.java +++ b/src/org/omegat/core/matching/NearString.java @@ -49,7 +49,26 @@ */ public class NearString { public enum MATCH_SOURCE { - MEMORY, TM, FILES + MEMORY(0x1F58A, '\u27BF'), + TM(0x1F9A3,'\u270E'), + FILES(0x1F4BF,'\u2707'), + SUBSEGMENTS(0x1F52A,'\u2702'); + + private String emoji; + private char dingbat; + + public String emoji() { + return this.emoji; + } + + public char dingbat() { + return this.dingbat; + } + + MATCH_SOURCE(int emoji, char dingbat) { + this.emoji = new String(Character.toChars(emoji)); + this.dingbat = dingbat; + } }; public enum SORT_KEY { diff --git a/src/org/omegat/core/statistics/FindMatches.java b/src/org/omegat/core/statistics/FindMatches.java index ebd8642061..300bd5c790 100644 --- a/src/org/omegat/core/statistics/FindMatches.java +++ b/src/org/omegat/core/statistics/FindMatches.java @@ -318,6 +318,7 @@ List search(String searchText, boolean fillSimilarityData, IStopped List fsrc = new ArrayList<>(segments.size()); List ftrans = new ArrayList<>(segments.size()); int maxPenalty = 0; + String first = OStrings.getString("MATCHES_THIS_PROJECT"); // multiple segments for (String onesrc : segments) { // find match for a separate segment. @@ -334,6 +335,13 @@ List search(String searchText, boolean fillSimilarityData, IStopped } } maxPenalty = Math.max(maxPenalty, segmentMatch.get(0).scores[0].penalty); + if ((segmentMatch.get(0).projs != null) && (segmentMatch.get(0).projs[0] != null)) { + if (segmentMatch.get(0).projs[0].length() > 0) { + first = segmentMatch.get(0).projs[0]; + } else { + first = OStrings.getString("MATCHES_THIS_PROJECT"); + } + } } else { fsrc.add(""); ftrans.add(""); @@ -343,7 +351,8 @@ List search(String searchText, boolean fillSimilarityData, IStopped PrepareTMXEntry entry = new PrepareTMXEntry(); entry.source = segmenter.glue(sourceLang, sourceLang, fsrc, spaces, brules); entry.translation = segmenter.glue(sourceLang, targetLang, ftrans, spaces, brules); - processEntry(null, entry, "", NearString.MATCH_SOURCE.TM, false, maxPenalty); + processEntry(null, entry, first + " " + OStrings.getString("MATCHES_SUBSEGMENTS_HINT"), + NearString.MATCH_SOURCE.SUBSEGMENTS, false, maxPenalty); } } // fill similarity data only for a result diff --git a/src/org/omegat/gui/matches/MatchesVarExpansion.java b/src/org/omegat/gui/matches/MatchesVarExpansion.java index 850daf5272..1d37a26825 100644 --- a/src/org/omegat/gui/matches/MatchesVarExpansion.java +++ b/src/org/omegat/gui/matches/MatchesVarExpansion.java @@ -90,11 +90,15 @@ public class MatchesVarExpansion extends VarExpansion { public static final String VAR_DIFF_REVERSED = "${diffReversed}"; public static final String VAR_SOURCE_LANGUAGE = "${sourceLanguage}"; public static final String VAR_TARGET_LANGUAGE = "${targetLanguage}"; + public static final String VAR_MATCH_SOURCE = "${matchSource}"; + public static final String VAR_MATCH_SOURCE_DINGBAT = "${matchSource-dingbat}"; + public static final String VAR_MATCH_SOURCE_EMOJI = "${matchSource-emoji}"; private static final String[] MATCHES_VARIABLES = { VAR_ID, VAR_SOURCE_TEXT, VAR_DIFF, VAR_DIFF_REVERSED, VAR_TARGET_TEXT, VAR_SCORE_BASE, VAR_SCORE_NOSTEM, VAR_SCORE_ADJUSTED, VAR_FILE_NAME_ONLY, VAR_FILE_PATH, VAR_FILE_SHORT_PATH, VAR_INITIAL_CREATION_ID, VAR_INITIAL_CREATION_DATE, - VAR_CHANGED_ID, VAR_CHANGED_DATE, VAR_FUZZY_FLAG, VAR_SOURCE_LANGUAGE, VAR_TARGET_LANGUAGE }; + VAR_CHANGED_ID, VAR_CHANGED_DATE, VAR_FUZZY_FLAG, VAR_SOURCE_LANGUAGE, VAR_TARGET_LANGUAGE, + VAR_MATCH_SOURCE, VAR_MATCH_SOURCE_DINGBAT, VAR_MATCH_SOURCE_EMOJI }; public static List getMatchesVariables() { return Collections.unmodifiableList(Arrays.asList(MATCHES_VARIABLES)); @@ -285,6 +289,11 @@ public String expandVariables(NearString match) { } else { localTemplate = localTemplate.replace(VAR_TARGET_TEXT, match.translation); } + + localTemplate = localTemplate.replace(VAR_MATCH_SOURCE, OStrings.getString("MATCHES_COMES_FROM_" + match.comesFrom)); + localTemplate = localTemplate.replace(VAR_MATCH_SOURCE_DINGBAT, Character.toString(match.comesFrom.dingbat())); + localTemplate = localTemplate.replace(VAR_MATCH_SOURCE_EMOJI, match.comesFrom.emoji()); + return localTemplate; }