From b78c83cc4a24ed731332a310cd6ed583e800d837 Mon Sep 17 00:00:00 2001 From: "dinesh.patil" Date: Wed, 25 Mar 2026 18:03:50 +0530 Subject: [PATCH] translator removed --- .../faq_n_privacy_n_terms_bloc.dart | 80 +------------------ pubspec.lock | 16 ---- pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 93 deletions(-) diff --git a/lib/profile/bloc/fnqPrivacyTerms/faq_n_privacy_n_terms_bloc.dart b/lib/profile/bloc/fnqPrivacyTerms/faq_n_privacy_n_terms_bloc.dart index f649406..3b7e4ba 100644 --- a/lib/profile/bloc/fnqPrivacyTerms/faq_n_privacy_n_terms_bloc.dart +++ b/lib/profile/bloc/fnqPrivacyTerms/faq_n_privacy_n_terms_bloc.dart @@ -1,5 +1,4 @@ import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:google_mlkit_translation/google_mlkit_translation.dart'; import '../../../localPreference/local_preference.dart'; import '../../repository/faq_n_privacy_n_terms_repository.dart'; @@ -10,12 +9,10 @@ class FAQnPrivacynTermsBloc extends Bloc { final FAQnPrivacynTermsRepository repository; - OnDeviceTranslator? _translator; - - FAQnPrivacynTermsBloc(this.repository) : super(FAQnPrivacynTermsInitial()) { + FAQnPrivacynTermsBloc(this.repository) + : super(FAQnPrivacynTermsInitial()) { on(_onFetchFAQnPrivacynTerms); on(_onToggleFAQItem); - on(_onTranslatePrivacyContent); } // --------------------------------------------------------------------------- @@ -50,87 +47,18 @@ class FAQnPrivacynTermsBloc current.expandedCategoryIndex == event.categoryIndex; final isSameItem = current.expandedItemIndex == event.tappedIndex; - // Tapping the already-open tile → close it; otherwise open the new one + // If same tile tapped → close it if (isSameCategory && isSameItem) { emit(current.copyWith( expandedCategoryIndex: -1, expandedItemIndex: -1, )); } else { + // Open new tile emit(current.copyWith( expandedCategoryIndex: event.categoryIndex, expandedItemIndex: event.tappedIndex, )); } } - - // --------------------------------------------------------------------------- - // Translate privacy-policy content (on-device, ML Kit) - // --------------------------------------------------------------------------- - - Future _onTranslatePrivacyContent( - TranslatePrivacyContentEvent event, - Emitter emit, - ) async { - final current = state; - if (current is! FAQnPrivacynTermsLoaded) return; - - final rawContent = event.rawContent; - final languageCode = await LocalPreference.getLanguage(); // e.g. 'hi', 'fr' - - // No translation needed for English — just store the raw content - if (languageCode == 'en' || languageCode == null || languageCode.isEmpty) { - emit(current.copyWith(translatedContent: rawContent, isTranslating: false)); - return; - } - - final targetLanguage = TranslateLanguage.values.firstWhere( - (l) => l.bcpCode == languageCode, - orElse: () => TranslateLanguage.english, - ); - - // Signal that translation is in progress - emit(current.copyWith(isTranslating: true)); - - try { - // Close previous translator if language changed - await _translator?.close(); - - _translator = OnDeviceTranslator( - sourceLanguage: TranslateLanguage.english, - targetLanguage: targetLanguage, - ); - - // Download the model if not already on-device - final modelManager = OnDeviceTranslatorModelManager(); - final isDownloaded = await modelManager.isModelDownloaded(languageCode); - if (!isDownloaded) { - await modelManager.downloadModel(languageCode); - } - - final translated = await _translator!.translateText(rawContent); - - // Emit only if bloc is still active (emitter guards this automatically) - emit(current.copyWith( - translatedContent: translated, - isTranslating: false, - )); - } catch (_) { - // Fallback to the original content on any error - emit(current.copyWith( - translatedContent: rawContent, - isTranslating: false, - )); - } - } - - // --------------------------------------------------------------------------- - // Cleanup - // --------------------------------------------------------------------------- - - @override - Future close() async { - await _translator?.close(); - return super.close(); - } } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 5151620..a3b4bbc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -605,22 +605,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.14+2" - google_mlkit_commons: - dependency: transitive - description: - name: google_mlkit_commons - sha256: "3e69fea4211727732cc385104e675ad1e40b29f12edd492ee52fa108423a6124" - url: "https://pub.dev" - source: hosted - version: "0.11.1" - google_mlkit_translation: - dependency: "direct main" - description: - name: google_mlkit_translation - sha256: "5cb1c156d926cb5f4795674835d9df480366e002a3a7e17729d2ee472aed11ae" - url: "https://pub.dev" - source: hosted - version: "0.13.1" gsettings: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b450b94..0875b2c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,7 +64,7 @@ dependencies: flutter_slidable: ^4.0.3 path_provider: ^2.1.5 share_plus: ^12.0.1 - google_mlkit_translation: ^0.13.1 +# google_mlkit_translation: ^0.13.1 url_launcher: ^6.3.2 open_filex: ^4.7.0 country_code_picker: ^3.4.1