You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if source language is neither in sourcePreferredTranslation nor preferredSources and BEHAVIOR_TRANSLATE_PREFERRED_OPTION_ONLY is set, actionLable for translation shouldn't be appended to this string.
132
170
if (!allowTranslation) {
133
171
actionStatus =ActionStatus.SHOWING_SOURCE
134
172
onContentChanged(this@PhraseSpannableBuilder)
135
173
return@launch
136
174
}
137
-
138
-
if (phraseDetected.languageCode.equals(
139
-
options.targetLanguageCode.toLowerCase(),
140
-
true
141
-
) || options.excludeSources.indexOfFirst {
142
-
it.equals(
143
-
phraseDetected.languageCode,
144
-
true
145
-
)
146
-
} >0
147
-
) {
148
-
actionStatus =ActionStatus.SHOWING_SOURCE
149
-
onContentChanged(this@PhraseSpannableBuilder)
150
-
return@launch
151
-
}
152
175
}
153
-
154
-
if (detectedMedium==null&&!behaviors.ignoreDetection()) {
176
+
// another check to ensure nullable phraseDetected is only allowed for BEHAVIOR_IGNORE_DETECTION
177
+
if (phraseDetected==null&&!behaviors.ignoreDetection()) {
155
178
onContentChanged(this@PhraseSpannableBuilder)
156
179
return@launch
157
180
}
181
+
// final check to confirm original text is not empty.
182
+
// also, actionLabel is appended only if BEHAVIOR_HIDE_TRANSLATE_PROMPT is not set and source is not same with the content of PhraseSpannableBuilder (to avoid text repetition)
158
183
if (!source.isNullOrBlank() &&!behaviors.hideTranslatePrompt() && (this@PhraseSpannableBuilder.toString() == source.toString())) {
* include this flag if Phrase should ignore language detection before processing translation.
57
+
* This is helpful if you already know the source language of the original text (in this case, ensure source language is pass to PhraseSpannableBuilder or
58
+
* PhraseTextView.prepare(), depending on the Implementation of Phrase you are using.)
0 commit comments