Skip to content

Commit 398b79d

Browse files
committed
handle translated blank cases
Signed-off-by: Julien Buret <jburet@voyages-sncf.com>
1 parent 01c7f90 commit 398b79d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

bot/connector-ga/src/main/kotlin/fr/vsct/tock/bot/connector/ga/extensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fun BotBus.richResponse(items: List<GAItem>, linkOutSuggestion: GALinkOutSuggest
148148

149149
fun BotBus.richResponse(items: List<GAItem>, vararg suggestions: GASuggestion): GARichResponse = richResponse(items, null, *suggestions)
150150

151-
fun BotBus.richResponse(text: String, linkOutSuggestion: GALinkOutSuggestion? = null): GARichResponse = richResponse(listOf(item(simpleResponse(textToSpeech = text))), linkOutSuggestion)
151+
fun BotBus.richResponse(text: String, linkOutSuggestion: GALinkOutSuggestion? = null): GARichResponse = richResponse(listOf(item(simpleResponse(text))), linkOutSuggestion)
152152

153153
fun BotBus.optionValueSpec(simpleSelect: GASimpleSelect? = null,
154154
listSelect: GAListSelect? = null,

translator/core/src/main/kotlin/fr/vsct/tock/translator/I18nLabel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data class I18nLabel(
3333
?: i18n.firstOrNull { it.locale.language == locale.language && it.interfaceType == userInterfaceType }
3434

3535
fun findLabel(locale: Locale): I18nLocalizedLabel?
36-
= i18n.firstOrNull { it.locale == locale }
37-
?: i18n.firstOrNull { it.locale.language == locale.language }
36+
= i18n.firstOrNull { it.locale == locale && it.label.isNotBlank() }
37+
?: i18n.firstOrNull { it.locale.language == locale.language && it.label.isNotBlank() }
3838

3939
}

translator/core/src/main/kotlin/fr/vsct/tock/translator/Translator.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ object Translator {
121121
voice.randomText()
122122
}
123123
} else {
124-
text?.randomText() ?: labelWithoutUserInterface(i18nLabel, defaultLabel, locale, textChat)
124+
text?.randomText() ?: labelWithoutUserInterface(i18nLabel, defaultLabel, locale, defaultInterface)
125125
}
126126
} else {
127-
return i18nLabel.findLabel(locale, userInterfaceType)?.randomText()
128-
?: labelWithoutUserInterface(i18nLabel, defaultLabel, locale, userInterfaceType)
127+
i18nLabel.findLabel(locale, userInterfaceType)?.randomText().run {
128+
if (isNullOrBlank()) {
129+
labelWithoutUserInterface(i18nLabel, defaultLabel, locale, userInterfaceType)
130+
} else {
131+
this!!
132+
}
133+
}
129134
}
130135
}
131136

0 commit comments

Comments
 (0)