translation updates

This commit is contained in:
Gabby Gurdin 2024-02-21 14:09:52 -05:00
parent 9ea5e85f1d
commit 7b91d14870
4 changed files with 13 additions and 1 deletions

View file

@ -51,6 +51,8 @@ class ModelKey {
static const String word = "word";
static const String lang = "lang";
static const String deepL = "deepl";
static const String offset = "offset";
static const String length = "length";
static const String langCode = 'lang_code';
static const String wordLang = "word_lang";
static const String lemma = "lemma";

View file

@ -37,6 +37,8 @@ class FullTextTranslationRequestModel {
String userL1;
String userL2;
bool? deepL;
int? offset;
int? length;
FullTextTranslationRequestModel({
required this.text,
@ -45,6 +47,8 @@ class FullTextTranslationRequestModel {
required this.userL2,
required this.userL1,
this.deepL = false,
this.offset,
this.length,
});
//PTODO throw error for null
@ -56,6 +60,8 @@ class FullTextTranslationRequestModel {
ModelKey.userL2: userL2,
ModelKey.userL1: userL1,
ModelKey.deepL: deepL,
ModelKey.offset: offset,
ModelKey.length: length,
};
}

View file

@ -32,4 +32,6 @@ class MessageTextSelection {
}
selectionStream.add(selectedText);
}
int get offset => messageText.indexOf(selectedText!);
}

View file

@ -73,11 +73,13 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
final resp = await FullTextTranslationRepo.translate(
accessToken: accessToken,
request: FullTextTranslationRequestModel(
text: widget.selection.selectedText!,
text: widget.selection.messageText,
tgtLang: translationLangCode()!,
userL1: l1Code!,
userL2: l2Code!,
srcLang: widget.messageEvent.messageDisplayLangCode,
length: widget.selection.selectedText!.length,
offset: widget.selection.offset,
),
);