Skip to content

Commit

Permalink
Add variables and symbols for COMES_FROM
Browse files Browse the repository at this point in the history
  • Loading branch information
t-cordonnier committed Dec 2, 2024
1 parent d1944d0 commit b2cf6a0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/org/omegat/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion src/org/omegat/core/matching/NearString.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/org/omegat/core/statistics/FindMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public List<NearString> 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
Expand Down
11 changes: 10 additions & 1 deletion src/org/omegat/gui/matches/MatchesVarExpansion.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ public class MatchesVarExpansion extends VarExpansion<NearString> {
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<String> getMatchesVariables() {
return Collections.unmodifiableList(Arrays.asList(MATCHES_VARIABLES));
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b2cf6a0

Please sign in to comment.