From 0175c958ef990742c48c37a9a1e44bc271a82072 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Mon, 28 Sep 2026 11:42:28 +0300 Subject: [PATCH] translation added. --- assets/langs/ar-SA.json | 11 +++- assets/langs/en-US.json | 11 +++- lib/generated/codegen_loader.g.dart | 22 +++++++- lib/generated/locale_keys.g.dart | 9 ++++ .../get_mobile_login_info_list_model.dart | 2 +- lib/ui/chatbot/chatbot_screen.dart | 50 ++++++++++++------- 6 files changed, 83 insertions(+), 22 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 916e8fb..93160f5 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -642,5 +642,14 @@ "yearsUsed": "سنوات الاستخدام", "faRequest": "طلب التخلص من FA", "showMore": "عرض المزيد", - "buyerDetails": "تفاصيل المشتري" + "buyerDetails": "تفاصيل المشتري", + "chatBot": "المساعد الذكي", + "helloAskMe": "مرحباً، اسألني", + "anything": "عن أي شيء...", + "thinking": "جاري التفكير", + "waitingForResponse": "في انتظار الرد...", + "typeAMessage": "اكتب رسالة...", + "initializingChatPleaseWait": "يرجى الانتظار، جاري تهيئة المحادثة...", + "am": "ص", + "pm": "م" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 5fcb35c..7637798 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -640,5 +640,14 @@ "yearsUsed": "Years Used", "faRequest":"FA Disposal Request", "showMore": "Show More", - "buyerDetails": "Buyer Details" + "buyerDetails": "Buyer Details", + "chatBot": "ChatBot", + "helloAskMe": "Hello, ask me", + "anything": "anything...", + "thinking": "Thinking", + "waitingForResponse": "Waiting for response...", + "typeAMessage": "Type a message..", + "initializingChatPleaseWait": "Please wait, initializing chat...", + "am": "AM", + "pm": "PM" } \ No newline at end of file diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 6feb438..0d41dfa 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -655,7 +655,16 @@ class CodegenLoader extends AssetLoader{ "yearsUsed": "سنوات الاستخدام", "faRequest": "طلب التخلص من FA", "showMore": "عرض المزيد", - "buyerDetails": "تفاصيل المشتري" + "buyerDetails": "تفاصيل المشتري", + "chatBot": "المساعد الذكي", + "helloAskMe": "مرحباً، اسألني", + "anything": "عن أي شيء...", + "thinking": "جاري التفكير", + "waitingForResponse": "في انتظار الرد...", + "typeAMessage": "اكتب رسالة...", + "initializingChatPleaseWait": "يرجى الانتظار، جاري تهيئة المحادثة...", + "am": "ص", + "pm": "م" }; static const Map _en_US = { "mohemm": "Mohemm", @@ -1298,7 +1307,16 @@ static const Map _en_US = { "yearsUsed": "Years Used", "faRequest": "FA Disposal Request", "showMore": "Show More", - "buyerDetails": "Buyer Details" + "buyerDetails": "Buyer Details", + "chatBot": "ChatBot", + "helloAskMe": "Hello, ask me", + "anything": "anything...", + "thinking": "Thinking", + "waitingForResponse": "Waiting for response...", + "typeAMessage": "Type a message..", + "initializingChatPleaseWait": "Please wait, initializing chat...", + "am": "AM", + "pm": "PM" }; static const Map> mapLocales = {"ar_SA": _ar_SA, "en_US": _en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 1a1cf95..9e9feac 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -628,5 +628,14 @@ abstract class LocaleKeys { static const faRequest = 'faRequest'; static const showMore = 'showMore'; static const buyerDetails = 'buyerDetails'; + static const chatBot = 'chatBot'; + static const helloAskMe = 'helloAskMe'; + static const anything = 'anything'; + static const thinking = 'thinking'; + static const waitingForResponse = 'waitingForResponse'; + static const typeAMessage = 'typeAMessage'; + static const initializingChatPleaseWait = 'initializingChatPleaseWait'; + static const am = 'am'; + static const pm = 'pm'; } diff --git a/lib/models/get_mobile_login_info_list_model.dart b/lib/models/get_mobile_login_info_list_model.dart index a2f7799..d544ef5 100644 --- a/lib/models/get_mobile_login_info_list_model.dart +++ b/lib/models/get_mobile_login_info_list_model.dart @@ -1,6 +1,6 @@ class GetMobileLoginInfoListModel { int? iD; - int? employeeID; + String? employeeID; int? channelID; int? companyID; String? deviceType; diff --git a/lib/ui/chatbot/chatbot_screen.dart b/lib/ui/chatbot/chatbot_screen.dart index dca43fa..a41b3d2 100644 --- a/lib/ui/chatbot/chatbot_screen.dart +++ b/lib/ui/chatbot/chatbot_screen.dart @@ -1,9 +1,12 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart'; @@ -53,7 +56,10 @@ class _ChatBotScreenState extends State { /// Start listening for speech void _startListening() async { - await _speechToText.listen(onResult: _onSpeechResult); + await _speechToText.listen( + onResult: _onSpeechResult, + localeId: AppState().isArabic(context) ? 'ar_SA' : 'en_US', + ); setState(() {}); } @@ -133,7 +139,7 @@ class _ChatBotScreenState extends State { } void _scrollToBottom() { - Future.delayed(const Duration(milliseconds: 100), () { + Future.delayed(const Duration(milliseconds: 100), () { if (_scrollController.hasClients) { _scrollController.animateTo(_scrollController.position.maxScrollExtent, duration: const Duration(milliseconds: 300), curve: Curves.easeOut); } @@ -142,7 +148,7 @@ class _ChatBotScreenState extends State { void _sendSuggestion(String text) { if (atlasChatTokenResponse == null) { - Utils.showToast("Please wait, initializing chat..."); + Utils.showToast(LocaleKeys.initializingChatPleaseWait.tr()); return; } _sendMessage(suggestionText: text); @@ -153,7 +159,7 @@ class _ChatBotScreenState extends State { return Scaffold( backgroundColor: MyColors.backgroundColor, appBar: AppBar( - title: const Text("ChatBot", style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2B353E))), + title: Text(LocaleKeys.chatBot.tr(), style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2B353E))), backgroundColor: MyColors.backgroundColor, centerTitle: false, ), @@ -169,18 +175,18 @@ class _ChatBotScreenState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - const Text("Hello, ask me", textAlign: TextAlign.center, style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2E303A))), - const Text("anything...", textAlign: TextAlign.center, style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2E303A))), + Text(LocaleKeys.helloAskMe.tr(), textAlign: TextAlign.center, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2E303A))), + Text(LocaleKeys.anything.tr(), textAlign: TextAlign.center, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2E303A))), const SizedBox(height: 50), - Wrap( + const Wrap( alignment: WrapAlignment.center, spacing: 8, runSpacing: 12, children: [ - _buildSuggestionChip("Nostalgia Perfume", () => _sendSuggestion("Nostalgia Perfume")), - _buildSuggestionChip("Al Nafoura", () => _sendSuggestion("Al Nafoura")), - _buildSuggestionChip("Al Nafoura", () => _sendSuggestion("Al Nafoura")), - _buildSuggestionChip("Al Jadi", () => _sendSuggestion("Al Jadi")), + // _buildSuggestionChip("Nostalgia Perfume", () => _sendSuggestion("Nostalgia Perfume")), + // _buildSuggestionChip("Al Nafoura", () => _sendSuggestion("Al Nafoura")), + // _buildSuggestionChip("Al Nafoura", () => _sendSuggestion("Al Nafoura")), + // _buildSuggestionChip("Al Jadi", () => _sendSuggestion("Al Jadi")), ], ), ], @@ -275,12 +281,16 @@ class _ChatBotScreenState extends State { } String _formatTimestamp(DateTime timestamp) { - String hour = timestamp.hour.toString().padLeft(2, '0'); - String minute = timestamp.minute.toString().padLeft(2, '0'); + int hourInt = timestamp.hour; + int minute = timestamp.minute; + String period = hourInt >= 12 ? LocaleKeys.pm.tr() : LocaleKeys.am.tr(); + int formattedHour = hourInt % 12 == 0 ? 12 : hourInt % 12; + String hour = formattedHour.toString().padLeft(2, '0'); + String min = minute.toString().padLeft(2, '0'); String month = timestamp.month.toString().padLeft(2, '0'); String day = timestamp.day.toString().padLeft(2, '0'); int year = timestamp.year; - return "$month/$day/$year $hour:$minute AM"; + return "$month/$day/$year $hour:$min $period"; } Widget _buildSuggestionChip(String label, VoidCallback onTap) { @@ -326,7 +336,7 @@ class _ChatBotScreenState extends State { maxLines: 1, textAlignVertical: TextAlignVertical.center, decoration: InputDecoration( - hintText: _isThinking ? 'Waiting for response...' : 'Type a message..', + hintText: _isThinking ? LocaleKeys.waitingForResponse.tr() : LocaleKeys.typeAMessage.tr(), hintStyle: const TextStyle(color: MyColors.hintTextColor, fontSize: 14, fontWeight: FontWeight.normal), border: InputBorder.none, isDense: true, @@ -353,7 +363,13 @@ class _ChatBotScreenState extends State { width: 48, height: 48, decoration: BoxDecoration(color: _isThinking ? MyColors.hintTextColor.withValues(alpha: 0.3) : MyColors.white, shape: BoxShape.circle), - child: Center(child: SvgPicture.asset("assets/icons/send.svg", colorFilter: _isThinking ? const ColorFilter.mode(MyColors.hintTextColor, BlendMode.srcIn) : null)), + child: Center( + child: SvgPicture.asset( + "assets/icons/send.svg", + matchTextDirection: true, + colorFilter: _isThinking ? const ColorFilter.mode(MyColors.hintTextColor, BlendMode.srcIn) : null, + ), + ), ), ), ], @@ -390,7 +406,7 @@ class _ThinkingDotsAnimationState extends State with Sing return Row( mainAxisSize: MainAxisSize.min, children: [ - const Text("Thinking", style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white)), + Text(LocaleKeys.thinking.tr(), style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white)), const SizedBox(width: 2), AnimatedBuilder( animation: _controller,