refactor: add localizations

This commit is contained in:
cogwheel0
2025-08-29 01:04:29 +05:30
parent 6b66b304b4
commit 7f2d89bc37
10 changed files with 100 additions and 8 deletions

View File

@@ -228,20 +228,21 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
const SizedBox(width: Spacing.xs), const SizedBox(width: Spacing.xs),
Text( Text(
() { () {
final l10n = AppLocalizations.of(context)!;
final rc = _reasoningContent!; final rc = _reasoningContent!;
final hasSummary = rc.summary.isNotEmpty; final hasSummary = rc.summary.isNotEmpty;
final isThinkingSummary = rc.summary.trim().toLowerCase() == 'thinking…' || rc.summary.trim().toLowerCase() == 'thinking...'; final isThinkingSummary = rc.summary.trim().toLowerCase() == 'thinking…' || rc.summary.trim().toLowerCase() == 'thinking...';
if (widget.isStreaming) { if (widget.isStreaming) {
// During streaming, prefer showing Thinking… // During streaming, prefer showing Thinking…
return hasSummary ? rc.summary : 'Thinking'; return hasSummary ? rc.summary : l10n.thinking;
} }
// After streaming ends: // After streaming ends:
if (rc.duration > 0) { if (rc.duration > 0) {
return 'Thought for ${rc.formattedDuration}'; return l10n.thoughtForDuration(rc.formattedDuration);
} }
// If summary was just the placeholder 'Thinking…', replace with a neutral title // If summary was just the placeholder 'Thinking…', replace with a neutral title
if (!hasSummary || isThinkingSummary) { if (!hasSummary || isThinkingSummary) {
return 'Thoughts'; return l10n.thoughts;
} }
return rc.summary; return rc.summary;
}(), }(),
@@ -514,7 +515,8 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: Spacing.xs), // Increase spacing between assistant name and typing indicator
const SizedBox(height: Spacing.md),
Row( Row(
children: [ children: [
_buildTypingDot(0), _buildTypingDot(0),

View File

@@ -251,5 +251,12 @@
"versionLabel": "Version: {version} ({build})", "versionLabel": "Version: {version} ({build})",
"@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}}, "@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}},
"githubRepository": "GitHub-Repository", "githubRepository": "GitHub-Repository",
"unableToLoadAppInfo": "App-Informationen konnten nicht geladen werden" "unableToLoadAppInfo": "App-Informationen konnten nicht geladen werden",
"thinking": "Denkt…",
"thoughts": "Gedanken",
"thoughtForDuration": "Gedacht für {duration}",
"@thoughtForDuration": {
"description": "Zeigt an, wie lange der Assistent nachgedacht hat.",
"placeholders": {"duration": {"type": "String", "example": "3 s"}}
}
} }

View File

@@ -275,5 +275,12 @@
"versionLabel": "Version: {version} ({build})", "versionLabel": "Version: {version} ({build})",
"@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}}, "@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}},
"githubRepository": "GitHub Repository", "githubRepository": "GitHub Repository",
"unableToLoadAppInfo": "Unable to load app info" "unableToLoadAppInfo": "Unable to load app info",
"thinking": "Thinking…",
"thoughts": "Thoughts",
"thoughtForDuration": "Thought for {duration}",
"@thoughtForDuration": {
"description": "Shows how long the assistant thought before replying.",
"placeholders": {"duration": {"type": "String", "example": "3s"}}
}
} }

View File

@@ -251,5 +251,12 @@
"versionLabel": "Version : {version} ({build})", "versionLabel": "Version : {version} ({build})",
"@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}}, "@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}},
"githubRepository": "Dépôt GitHub", "githubRepository": "Dépôt GitHub",
"unableToLoadAppInfo": "Impossible de charger les informations de l'application" "unableToLoadAppInfo": "Impossible de charger les informations de l'application",
"thinking": "Réflexion…",
"thoughts": "Réflexions",
"thoughtForDuration": "A réfléchi pendant {duration}",
"@thoughtForDuration": {
"description": "Indique la durée de réflexion de l'assistant.",
"placeholders": {"duration": {"type": "String", "example": "3 s"}}
}
} }

View File

@@ -251,5 +251,12 @@
"versionLabel": "Versione: {version} ({build})", "versionLabel": "Versione: {version} ({build})",
"@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}}, "@versionLabel": {"placeholders": {"version": {"type": "String"}, "build": {"type": "String"}}},
"githubRepository": "Repository GitHub", "githubRepository": "Repository GitHub",
"unableToLoadAppInfo": "Impossibile caricare le informazioni dell'app" "unableToLoadAppInfo": "Impossibile caricare le informazioni dell'app",
"thinking": "Sta pensando…",
"thoughts": "Pensieri",
"thoughtForDuration": "Ha pensato per {duration}",
"@thoughtForDuration": {
"description": "Mostra per quanto tempo ha pensato l'assistente.",
"placeholders": {"duration": {"type": "String", "example": "3 s"}}
}
} }

View File

@@ -1454,6 +1454,24 @@ abstract class AppLocalizations {
/// In en, this message translates to: /// In en, this message translates to:
/// **'Unable to load app info'** /// **'Unable to load app info'**
String get unableToLoadAppInfo; String get unableToLoadAppInfo;
/// No description provided for @thinking.
///
/// In en, this message translates to:
/// **'Thinking…'**
String get thinking;
/// No description provided for @thoughts.
///
/// In en, this message translates to:
/// **'Thoughts'**
String get thoughts;
/// Shows how long the assistant thought before replying.
///
/// In en, this message translates to:
/// **'Thought for {duration}'**
String thoughtForDuration(String duration);
} }
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> { class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {

View File

@@ -716,4 +716,15 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get unableToLoadAppInfo => 'App-Informationen konnten nicht geladen werden'; String get unableToLoadAppInfo => 'App-Informationen konnten nicht geladen werden';
@override
String get thinking => 'Denkt…';
@override
String get thoughts => 'Gedanken';
@override
String thoughtForDuration(String duration) {
return 'Gedacht für $duration';
}
} }

View File

@@ -716,4 +716,15 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get unableToLoadAppInfo => 'Unable to load app info'; String get unableToLoadAppInfo => 'Unable to load app info';
@override
String get thinking => 'Thinking…';
@override
String get thoughts => 'Thoughts';
@override
String thoughtForDuration(String duration) {
return 'Thought for $duration';
}
} }

View File

@@ -716,4 +716,15 @@ class AppLocalizationsFr extends AppLocalizations {
@override @override
String get unableToLoadAppInfo => 'Impossible de charger les informations de l\'application'; String get unableToLoadAppInfo => 'Impossible de charger les informations de l\'application';
@override
String get thinking => 'Réflexion…';
@override
String get thoughts => 'Réflexions';
@override
String thoughtForDuration(String duration) {
return 'A réfléchi pendant $duration';
}
} }

View File

@@ -716,4 +716,15 @@ class AppLocalizationsIt extends AppLocalizations {
@override @override
String get unableToLoadAppInfo => 'Impossibile caricare le informazioni dell\'app'; String get unableToLoadAppInfo => 'Impossibile caricare le informazioni dell\'app';
@override
String get thinking => 'Sta pensando…';
@override
String get thoughts => 'Pensieri';
@override
String thoughtForDuration(String duration) {
return 'Ha pensato per $duration';
}
} }