From b2cf6a04eb1d6af40fd1bf048d07feaee0915f7a Mon Sep 17 00:00:00 2001 From: Thomas CORDONNIER Date: Mon, 2 Dec 2024 11:43:14 +0100 Subject: [PATCH] Add variables and symbols for COMES_FROM --- src/org/omegat/Bundle.properties | 5 +++++ src/org/omegat/core/matching/NearString.java | 21 ++++++++++++++++++- .../omegat/core/statistics/FindMatches.java | 2 +- .../gui/matches/MatchesVarExpansion.java | 11 +++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/org/omegat/Bundle.properties b/src/org/omegat/Bundle.properties index 5ca557932b..7d02a9d11f 100644 --- a/src/org/omegat/Bundle.properties +++ b/src/org/omegat/Bundle.properties @@ -2162,6 +2162,11 @@ MATCHES_MULTI_FILE_HINT=(+{0}\u00A0more) MATCHES_SUBSEGMENTS_HINT=(+subsegments) +MATCHES_COMES_FROM_TM=From TM +MATCHES_COMES_FROM_FILES=Files +MATCHES_COMES_FROM_MEMORY=From Project +MATCHES_COMES_FROM_SUBSEGMENTS=Sub-segmented match + MATCHES_OPEN_PREFERENCES=TM Matching Options # Dictionary area popup menu diff --git a/src/org/omegat/core/matching/NearString.java b/src/org/omegat/core/matching/NearString.java index 827da2f4e5..3e90b0b1b4 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 d2a1ec412d..b22dc6919d 100644 --- a/src/org/omegat/core/statistics/FindMatches.java +++ b/src/org/omegat/core/statistics/FindMatches.java @@ -311,7 +311,7 @@ public List search(String searchText, boolean requiresTranslation, b entry.source = segmenter.glue(sourceLang, sourceLang, fsrc, spaces, brules); entry.translation = segmenter.glue(sourceLang, targetLang, ftrans, spaces, brules); processEntry(null, entry, first + " " + OStrings.getString("MATCHES_SUBSEGMENTS_HINT"), - NearString.MATCH_SOURCE.TM, false, 0); + NearString.MATCH_SOURCE.SUBSEGMENTS, false, 0); } } // 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; }