Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change label for subsegments #1224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/org/omegat/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/org/omegat/Bundle_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
11 changes: 10 additions & 1 deletion src/org/omegat/core/statistics/FindMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ List<NearString> search(String searchText, boolean fillSimilarityData, IStopped
List<String> fsrc = new ArrayList<>(segments.size());
List<String> 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.
Expand All @@ -334,6 +335,13 @@ List<NearString> 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("");
Expand All @@ -343,7 +351,8 @@ List<NearString> 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
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
Loading