feat: 优化首字母大写

This commit is contained in:
xkeyC 2024-11-23 21:59:00 +08:00
parent 772f329407
commit 4297b2f530

View File

@ -168,7 +168,14 @@ class InputMethodDialogUIModel extends _$InputMethodDialogUIModel {
try {
final r = await Api.doGoogleTranslate(sourceText);
if (r != null) {
_destTextCtrl?.text = "$content\n[en] $r";
String resultText = r;
// resultText
if (content.isNotEmpty) {
final firstChar = resultText.characters.first;
resultText =
resultText.replaceFirst(firstChar, firstChar.toUpperCase());
}
_destTextCtrl?.text = "$content\n[en] $resultText";
if (state.enableAutoCopy || webMessage) {
Clipboard.setData(ClipboardData(text: _destTextCtrl?.text ?? ""));
}