Skip to content

Commit 343f3b9

Browse files
committed
Retry language translation.
1 parent e3c9729 commit 343f3b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ public async Task<T> Translate<T>(Agent router, string messageId, T data, string
6262
Id = i + 1,
6363
Text = text
6464
}).ToList();
65-
var translatedStringList = await InnerTranslate(texts, language, template);
6665

6766
try
6867
{
68+
var translatedStringList = await InnerTranslate(texts, language, template);
69+
70+
int retry = 0;
71+
while (translatedStringList.Texts.Length != texts.Count && retry < 3)
72+
{
73+
translatedStringList = await InnerTranslate(texts, language, template);
74+
retry++;
75+
}
76+
6977
// Override language if it's Unknown, it's used to output the corresponding language.
7078
var states = _services.GetRequiredService<IConversationStateService>();
7179
if (!states.ContainsState(StateConst.LANGUAGE))

0 commit comments

Comments
 (0)