From c858ac40f51e9ef293be11b2dd7c46b1b4ffc7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Tue, 9 Dec 2025 07:47:46 +0100 Subject: [PATCH] Add translations for scribe module Added a separated ScribeLocalizations to keep it separated from main app. --- lib/l10n/intl_messages.arb | 2 +- lib/main.dart | 2 + scribe/lib/scribe/ai/l10n/intl_en.arb | 129 +++++++++++++++ scribe/lib/scribe/ai/l10n/intl_fr.arb | 129 +++++++++++++++ scribe/lib/scribe/ai/l10n/intl_messages.arb | 129 +++++++++++++++ scribe/lib/scribe/ai/l10n/intl_ru.arb | 129 +++++++++++++++ scribe/lib/scribe/ai/l10n/intl_vi.arb | 129 +++++++++++++++ .../localizations/scribe_localizations.dart | 147 ++++++++++++++++++ .../ai/presentation/model/ai_action.dart | 10 +- .../model/ai_scribe_menu_action.dart | 49 +++--- scribe/pubspec.lock | 24 ++- scribe/pubspec.yaml | 12 ++ scripts/prebuild.sh | 6 + 13 files changed, 866 insertions(+), 31 deletions(-) create mode 100644 scribe/lib/scribe/ai/l10n/intl_en.arb create mode 100644 scribe/lib/scribe/ai/l10n/intl_fr.arb create mode 100644 scribe/lib/scribe/ai/l10n/intl_messages.arb create mode 100644 scribe/lib/scribe/ai/l10n/intl_ru.arb create mode 100644 scribe/lib/scribe/ai/l10n/intl_vi.arb create mode 100644 scribe/lib/scribe/ai/localizations/scribe_localizations.dart diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index 8fb163241..ec2a57bcb 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2025-12-09T11:34:40.710644", + "@@last_modified": "2025-12-09T13:09:50.879268", "initializing_data": "Initializing data...", "@initializing_data": { "type": "text", diff --git a/lib/main.dart b/lib/main.dart index dcdb4d04a..5cebea408 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ import 'package:get/get.dart'; import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart'; import 'package:tmail_ui_user/main/bindings/main_bindings.dart'; import 'package:tmail_ui_user/main/deep_links/deep_links_manager.dart'; +import 'package:scribe/scribe/ai/localizations/scribe_localizations.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart'; import 'package:tmail_ui_user/main/localizations/localization_service.dart'; @@ -75,6 +76,7 @@ class _TMailAppState extends State { supportedLocales: LocalizationService.supportedLocales, localizationsDelegates: const [ AppLocalizationsDelegate(), + ScribeLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, diff --git a/scribe/lib/scribe/ai/l10n/intl_en.arb b/scribe/lib/scribe/ai/l10n/intl_en.arb new file mode 100644 index 000000000..139ccf8ea --- /dev/null +++ b/scribe/lib/scribe/ai/l10n/intl_en.arb @@ -0,0 +1,129 @@ +{ + "@@last_modified": "2025-12-09T06:57:10.911448", + "categoryCorrectGrammar": "Correct grammar", + "@categoryCorrectGrammar": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryImprove": "Improve", + "@categoryImprove": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryChangeTone": "Change tone", + "@categoryChangeTone": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryTranslate": "Translate", + "@categoryTranslate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMakeShorter": "Make it shorter", + "@actionMakeShorter": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionExpandContext": "Expand context", + "@actionExpandContext": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionEmojify": "Emojify", + "@actionEmojify": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionTransformToBullets": "Transform to bullets", + "@actionTransformToBullets": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreProfessional": "More professional", + "@actionMoreProfessional": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreCasual": "More casual", + "@actionMoreCasual": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMorePolite": "More polite", + "@actionMorePolite": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageFrench": "French", + "@languageFrench": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageEnglish": "English", + "@languageEnglish": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageRussian": "Russian", + "@languageRussian": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageVietnamese": "Vietnamese", + "@languageVietnamese": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "inputPlaceholder": "Help me write", + "@inputPlaceholder": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "customPromptAction": "Help me write", + "@customPromptAction": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "generatingResponse": "Generating AI response...", + "@generatingResponse": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "failedToGenerate": "Failed to generate AI response", + "@failedToGenerate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "noDataReceived": "No data received", + "@noDataReceived": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "insertButton": "Insert", + "@insertButton": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + } +} \ No newline at end of file diff --git a/scribe/lib/scribe/ai/l10n/intl_fr.arb b/scribe/lib/scribe/ai/l10n/intl_fr.arb new file mode 100644 index 000000000..0a53f2e9a --- /dev/null +++ b/scribe/lib/scribe/ai/l10n/intl_fr.arb @@ -0,0 +1,129 @@ +{ + "@@last_modified": "2025-12-09T07:30:00.000000", + "categoryCorrectGrammar": "Corriger la grammaire", + "@categoryCorrectGrammar": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryImprove": "Améliorer", + "@categoryImprove": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryChangeTone": "Changer le ton", + "@categoryChangeTone": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryTranslate": "Traduire", + "@categoryTranslate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMakeShorter": "Raccourcir", + "@actionMakeShorter": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionExpandContext": "Développer", + "@actionExpandContext": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionEmojify": "Ajouter des émojis", + "@actionEmojify": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionTransformToBullets": "Transformer en liste", + "@actionTransformToBullets": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreProfessional": "Plus professionnel", + "@actionMoreProfessional": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreCasual": "Plus décontracté", + "@actionMoreCasual": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMorePolite": "Plus poli", + "@actionMorePolite": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageFrench": "Français", + "@languageFrench": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageEnglish": "Anglais", + "@languageEnglish": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageRussian": "Russe", + "@languageRussian": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageVietnamese": "Vietnamien", + "@languageVietnamese": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "inputPlaceholder": "Aidez-moi à écrire", + "@inputPlaceholder": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "customPromptAction": "Aidez-moi à écrire", + "@customPromptAction": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "generatingResponse": "Génération de la réponse IA...", + "@generatingResponse": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "failedToGenerate": "Échec de la génération de la réponse IA", + "@failedToGenerate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "noDataReceived": "Aucune donnée reçue", + "@noDataReceived": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "insertButton": "Insérer", + "@insertButton": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + } +} diff --git a/scribe/lib/scribe/ai/l10n/intl_messages.arb b/scribe/lib/scribe/ai/l10n/intl_messages.arb new file mode 100644 index 000000000..ac45198fa --- /dev/null +++ b/scribe/lib/scribe/ai/l10n/intl_messages.arb @@ -0,0 +1,129 @@ +{ + "@@last_modified": "2025-12-09T13:09:52.614790", + "categoryCorrectGrammar": "Correct grammar", + "@categoryCorrectGrammar": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryImprove": "Improve", + "@categoryImprove": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryChangeTone": "Change tone", + "@categoryChangeTone": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryTranslate": "Translate", + "@categoryTranslate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMakeShorter": "Make it shorter", + "@actionMakeShorter": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionExpandContext": "Expand context", + "@actionExpandContext": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionEmojify": "Emojify", + "@actionEmojify": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionTransformToBullets": "Transform to bullets", + "@actionTransformToBullets": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreProfessional": "More professional", + "@actionMoreProfessional": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreCasual": "More casual", + "@actionMoreCasual": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMorePolite": "More polite", + "@actionMorePolite": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageFrench": "French", + "@languageFrench": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageEnglish": "English", + "@languageEnglish": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageRussian": "Russian", + "@languageRussian": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageVietnamese": "Vietnamese", + "@languageVietnamese": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "inputPlaceholder": "Help me write", + "@inputPlaceholder": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "customPromptAction": "Help me write", + "@customPromptAction": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "generatingResponse": "Generating AI response...", + "@generatingResponse": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "failedToGenerate": "Failed to generate AI response", + "@failedToGenerate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "noDataReceived": "No data received", + "@noDataReceived": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "insertButton": "Insert", + "@insertButton": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + } +} \ No newline at end of file diff --git a/scribe/lib/scribe/ai/l10n/intl_ru.arb b/scribe/lib/scribe/ai/l10n/intl_ru.arb new file mode 100644 index 000000000..b894b86fb --- /dev/null +++ b/scribe/lib/scribe/ai/l10n/intl_ru.arb @@ -0,0 +1,129 @@ +{ + "@@last_modified": "2025-12-09T07:30:00.000000", + "categoryCorrectGrammar": "Исправить грамматику", + "@categoryCorrectGrammar": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryImprove": "Улучшить", + "@categoryImprove": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryChangeTone": "Изменить тон", + "@categoryChangeTone": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryTranslate": "Перевести", + "@categoryTranslate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMakeShorter": "Сделать короче", + "@actionMakeShorter": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionExpandContext": "Расширить контекст", + "@actionExpandContext": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionEmojify": "Добавить эмодзи", + "@actionEmojify": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionTransformToBullets": "Преобразовать в список", + "@actionTransformToBullets": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreProfessional": "Более профессионально", + "@actionMoreProfessional": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreCasual": "Более неформально", + "@actionMoreCasual": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMorePolite": "Более вежливо", + "@actionMorePolite": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageFrench": "Французский", + "@languageFrench": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageEnglish": "Английский", + "@languageEnglish": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageRussian": "Русский", + "@languageRussian": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageVietnamese": "Вьетнамский", + "@languageVietnamese": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "inputPlaceholder": "Помогите мне написать", + "@inputPlaceholder": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "customPromptAction": "Помогите мне написать", + "@customPromptAction": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "generatingResponse": "Генерация ответа ИИ...", + "@generatingResponse": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "failedToGenerate": "Не удалось сгенерировать ответ ИИ", + "@failedToGenerate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "noDataReceived": "Данные не получены", + "@noDataReceived": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "insertButton": "Вставить", + "@insertButton": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + } +} diff --git a/scribe/lib/scribe/ai/l10n/intl_vi.arb b/scribe/lib/scribe/ai/l10n/intl_vi.arb new file mode 100644 index 000000000..255caaaf7 --- /dev/null +++ b/scribe/lib/scribe/ai/l10n/intl_vi.arb @@ -0,0 +1,129 @@ +{ + "@@last_modified": "2025-12-09T07:30:00.000000", + "categoryCorrectGrammar": "Sửa ngữ pháp", + "@categoryCorrectGrammar": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryImprove": "Cải thiện", + "@categoryImprove": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryChangeTone": "Thay đổi giọng điệu", + "@categoryChangeTone": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "categoryTranslate": "Dịch", + "@categoryTranslate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMakeShorter": "Làm ngắn gọn hơn", + "@actionMakeShorter": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionExpandContext": "Mở rộng ngữ cảnh", + "@actionExpandContext": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionEmojify": "Thêm biểu tượng cảm xúc", + "@actionEmojify": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionTransformToBullets": "Chuyển thành danh sách", + "@actionTransformToBullets": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreProfessional": "Chuyên nghiệp hơn", + "@actionMoreProfessional": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMoreCasual": "Thân mật hơn", + "@actionMoreCasual": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "actionMorePolite": "Lịch sự hơn", + "@actionMorePolite": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageFrench": "Tiếng Pháp", + "@languageFrench": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageEnglish": "Tiếng Anh", + "@languageEnglish": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageRussian": "Tiếng Nga", + "@languageRussian": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "languageVietnamese": "Tiếng Việt", + "@languageVietnamese": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "inputPlaceholder": "Giúp tôi viết", + "@inputPlaceholder": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "customPromptAction": "Giúp tôi viết", + "@customPromptAction": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "generatingResponse": "Đang tạo phản hồi AI...", + "@generatingResponse": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "failedToGenerate": "Không thể tạo phản hồi AI", + "@failedToGenerate": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "noDataReceived": "Không nhận được dữ liệu", + "@noDataReceived": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "insertButton": "Chèn", + "@insertButton": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + } +} diff --git a/scribe/lib/scribe/ai/localizations/scribe_localizations.dart b/scribe/lib/scribe/ai/localizations/scribe_localizations.dart new file mode 100644 index 000000000..1b7bfb76d --- /dev/null +++ b/scribe/lib/scribe/ai/localizations/scribe_localizations.dart @@ -0,0 +1,147 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:scribe/scribe/ai/l10n/messages_all.dart'; + +class ScribeLocalizations { + + static ScribeLocalizations? of(BuildContext context) { + return Localizations.of(context, ScribeLocalizations); + } + + static Future load(Locale locale) async { + final name = locale.countryCode == null ? locale.languageCode : locale.toString(); + + final localeName = Intl.canonicalizedLocale(name); + + return initializeMessages(localeName).then((_) { + Intl.defaultLocale = localeName; + return ScribeLocalizations(); + }); + } + + static const LocalizationsDelegate delegate = _ScribeLocalizationsDelegate(); + + // Menu Categories + String get categoryCorrectGrammar { + return Intl.message('Correct grammar', + name: 'categoryCorrectGrammar'); + } + + String get categoryImprove { + return Intl.message('Improve', + name: 'categoryImprove'); + } + + String get categoryChangeTone { + return Intl.message('Change tone', + name: 'categoryChangeTone'); + } + + String get categoryTranslate { + return Intl.message('Translate', + name: 'categoryTranslate'); + } + + // Menu Actions - Improve + String get actionMakeShorter { + return Intl.message('Make it shorter', + name: 'actionMakeShorter'); + } + + String get actionExpandContext { + return Intl.message('Expand context', + name: 'actionExpandContext'); + } + + String get actionEmojify { + return Intl.message('Emojify', + name: 'actionEmojify'); + } + + String get actionTransformToBullets { + return Intl.message('Transform to bullets', + name: 'actionTransformToBullets'); + } + + // Menu Actions - Change Tone + String get actionMoreProfessional { + return Intl.message('More professional', + name: 'actionMoreProfessional'); + } + + String get actionMoreCasual { + return Intl.message('More casual', + name: 'actionMoreCasual'); + } + + String get actionMorePolite { + return Intl.message('More polite', + name: 'actionMorePolite'); + } + + // Menu Actions - Translate + String get languageFrench { + return Intl.message('French', + name: 'languageFrench'); + } + + String get languageEnglish { + return Intl.message('English', + name: 'languageEnglish'); + } + + String get languageRussian { + return Intl.message('Russian', + name: 'languageRussian'); + } + + String get languageVietnamese { + return Intl.message('Vietnamese', + name: 'languageVietnamese'); + } + + // Input Bar + String get inputPlaceholder { + return Intl.message('Help me write', + name: 'inputPlaceholder'); + } + + String get customPromptAction { + return Intl.message('Help me write', + name: 'customPromptAction'); + } + + // Suggestion Dialog + String get generatingResponse { + return Intl.message('Generating AI response...', + name: 'generatingResponse'); + } + + String get failedToGenerate { + return Intl.message('Failed to generate AI response', + name: 'failedToGenerate'); + } + + String get noDataReceived { + return Intl.message('No data received', + name: 'noDataReceived'); + } + + String get insertButton { + return Intl.message('Insert', + name: 'insertButton'); + } +} + +class _ScribeLocalizationsDelegate extends LocalizationsDelegate { + const _ScribeLocalizationsDelegate(); + + @override + bool isSupported(Locale locale) => ['en', 'fr', 'ru', 'vi'].contains(locale.languageCode); + + @override + Future load(Locale locale) => ScribeLocalizations.load(locale); + + @override + bool shouldReload(_ScribeLocalizationsDelegate old) => false; +} diff --git a/scribe/lib/scribe/ai/presentation/model/ai_action.dart b/scribe/lib/scribe/ai/presentation/model/ai_action.dart index 03c08b192..dca146825 100644 --- a/scribe/lib/scribe/ai/presentation/model/ai_action.dart +++ b/scribe/lib/scribe/ai/presentation/model/ai_action.dart @@ -1,9 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:scribe/scribe/ai/localizations/scribe_localizations.dart'; import 'package:scribe/scribe/ai/presentation/model/ai_scribe_menu_action.dart'; sealed class AIAction { const AIAction(); - String get label; + String getLabel(BuildContext context); } class PredefinedAction extends AIAction { @@ -12,7 +14,7 @@ class PredefinedAction extends AIAction { const PredefinedAction(this.action); @override - String get label => action.fullLabel; + String getLabel(BuildContext context) => action.getFullLabel(context); } class CustomPromptAction extends AIAction { @@ -21,5 +23,7 @@ class CustomPromptAction extends AIAction { const CustomPromptAction(this.prompt); @override - String get label => 'Help me write'; + String getLabel(BuildContext context) { + return ScribeLocalizations.of(context)!.customPromptAction; + } } diff --git a/scribe/lib/scribe/ai/presentation/model/ai_scribe_menu_action.dart b/scribe/lib/scribe/ai/presentation/model/ai_scribe_menu_action.dart index 8a1985544..ab16fa9f8 100644 --- a/scribe/lib/scribe/ai/presentation/model/ai_scribe_menu_action.dart +++ b/scribe/lib/scribe/ai/presentation/model/ai_scribe_menu_action.dart @@ -1,3 +1,6 @@ +import 'package:flutter/material.dart'; +import 'package:scribe/scribe/ai/localizations/scribe_localizations.dart'; + enum AIScribeMenuAction { correctGrammar, improveMakeShorter, @@ -12,32 +15,33 @@ enum AIScribeMenuAction { translateRussian, translateVietnamese; - String get label { + String getLabel(BuildContext context) { + final localizations = ScribeLocalizations.of(context)!; switch (this) { case AIScribeMenuAction.correctGrammar: - return 'Correct grammar'; + return localizations.categoryCorrectGrammar; case AIScribeMenuAction.improveMakeShorter: - return 'Make it shorter'; + return localizations.actionMakeShorter; case AIScribeMenuAction.improveExpandContext: - return 'Expand context'; + return localizations.actionExpandContext; case AIScribeMenuAction.improveEmojify: - return 'Emojify'; + return localizations.actionEmojify; case AIScribeMenuAction.improveTransformToBullets: - return 'Transform to bullets'; + return localizations.actionTransformToBullets; case AIScribeMenuAction.changeToneProfessional: - return 'More professional'; + return localizations.actionMoreProfessional; case AIScribeMenuAction.changeToneCasual: - return 'More casual'; + return localizations.actionMoreCasual; case AIScribeMenuAction.changeTonePolite: - return 'More polite'; + return localizations.actionMorePolite; case AIScribeMenuAction.translateFrench: - return 'French'; + return localizations.languageFrench; case AIScribeMenuAction.translateEnglish: - return 'English'; + return localizations.languageEnglish; case AIScribeMenuAction.translateRussian: - return 'Russian'; + return localizations.languageRussian; case AIScribeMenuAction.translateVietnamese: - return 'Vietnamese'; + return localizations.languageVietnamese; } } @@ -62,12 +66,12 @@ enum AIScribeMenuAction { } } - String get fullLabel { - final categoryLabel = category.label; + String getFullLabel(BuildContext context) { + final categoryLabel = category.getLabel(context); if (category.hasSubmenu) { - return '$categoryLabel > $label'; + return '$categoryLabel > ${getLabel(context)}'; } else { - return label; + return getLabel(context); } } } @@ -78,16 +82,17 @@ enum AIScribeMenuCategory { changeTone, translate; - String get label { + String getLabel(BuildContext context) { + final localizations = ScribeLocalizations.of(context)!; switch (this) { case AIScribeMenuCategory.correctGrammar: - return 'Correct grammar'; + return localizations.categoryCorrectGrammar; case AIScribeMenuCategory.improve: - return 'Improve'; + return localizations.categoryImprove; case AIScribeMenuCategory.changeTone: - return 'Change tone'; + return localizations.categoryChangeTone; case AIScribeMenuCategory.translate: - return 'Translate'; + return localizations.categoryTranslate; } } diff --git a/scribe/pubspec.lock b/scribe/pubspec.lock index 9c93c25ce..4f62c1a5e 100644 --- a/scribe/pubspec.lock +++ b/scribe/pubspec.lock @@ -541,6 +541,11 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_svg: dependency: transitive description: @@ -648,13 +653,22 @@ packages: source: hosted version: "4.5.4" intl: - dependency: transitive + dependency: "direct main" description: name: intl sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" url: "https://pub.dev" source: hosted version: "0.20.2" + intl_generator: + dependency: "direct dev" + description: + path: "." + ref: master + resolved-ref: "20ca4d1c3ed3a7e9e2e86700af928ded9db4ff11" + url: "https://github.com/linagora/intl_generator.git" + source: git + version: "0.4.1" io: dependency: transitive description: @@ -867,10 +881,10 @@ packages: dependency: transitive description: name: petitparser - sha256: "1a97266a94f7350d30ae522c0af07890c70b8e62c71e8e3920d1db4d23c057d1" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 url: "https://pub.dev" source: hosted - version: "7.0.1" + version: "5.4.0" platform: dependency: transitive description: @@ -1281,10 +1295,10 @@ packages: dependency: transitive description: name: xml - sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" url: "https://pub.dev" source: hosted - version: "6.6.1" + version: "6.3.0" yaml: dependency: transitive description: diff --git a/scribe/pubspec.yaml b/scribe/pubspec.yaml index d288d2f19..3e62f1652 100644 --- a/scribe/pubspec.yaml +++ b/scribe/pubspec.yaml @@ -10,6 +10,9 @@ dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter + ### Local dependencies ### core: path: ../core @@ -23,6 +26,8 @@ dependencies: pointer_interceptor: 0.10.1+2 + intl: 0.20.2 + dev_dependencies: flutter_test: sdk: flutter @@ -31,6 +36,13 @@ dev_dependencies: json_serializable: 6.6.1 + ### Original dependency is abandoned, so we use fork + ### https://github.com/linagora/intl_generator/pull/1 + intl_generator: + git: + url: https://github.com/linagora/intl_generator.git + ref: master + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index fd412c950..8293f779a 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -25,3 +25,9 @@ flutter pub get dart run build_runner build --delete-conflicting-outputs && dart run intl_generator:extract_to_arb --output-dir=./lib/l10n lib/main/localizations/app_localizations.dart && dart run intl_generator:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/main/localizations/app_localizations.dart lib/l10n/intl*.arb + +# For scribe module localizations +cd scribe +dart run intl_generator:extract_to_arb --output-dir=./lib/scribe/ai/l10n lib/scribe/ai/localizations/scribe_localizations.dart && + dart run intl_generator:generate_from_arb --output-dir=lib/scribe/ai/l10n --no-use-deferred-loading lib/scribe/ai/localizations/scribe_localizations.dart lib/scribe/ai/l10n/intl*.arb +cd ../