adding multilingual support

This commit is contained in:
Azmat-7860
2026-10-03 15:04:48 +05:30
parent 3785ea1e45
commit 0d7785b242
51 changed files with 3007 additions and 250 deletions
@@ -2,6 +2,7 @@ import 'package:base_project/commans/widgets/custom_textform_field.dart';
import 'package:base_project/commans/widgets/custome_elevated_button.dart';
import 'package:base_project/core/constants/ui_constants.dart';
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
import 'package:base_project/l10n/app_localizations.dart';
import 'package:base_project/utils/validator/text_feild_validator.dart';
import 'package:base_project/view/auth/sign_up_view.dart';
import 'package:base_project/view_model/auth/auth_view_model.dart';
@@ -231,7 +232,8 @@ class _AdminRegViewState extends State<AdminRegView>
builder: (context, provider, child) {
return MyCustomElevatedButton(
isLoading: provider.isLoading,
child: const Text("Register Company"),
child: Text(AppLocalizations.of(context)!
.registerCompany),
onPressed: () async {
if (_formKey.currentState!.validate()) {
final Map<String, dynamic> signUpData = {
+16 -11
View File
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../l10n/app_localizations.dart';
class GetOtpView extends StatefulWidget {
const GetOtpView({super.key});
@@ -483,7 +484,7 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
child: Column(
children: [
Text(
'Get OTP',
AppLocalizations.of(context)!.getOtp,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
@@ -493,7 +494,7 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
),
const SizedBox(height: UIConstants.spacing12),
Text(
'Enter your email to receive a one-time password',
AppLocalizations.of(context)!.otpEmailPrompt,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: colorScheme.onSurface.withOpacity(0.8),
fontWeight: FontWeight.w400,
@@ -543,8 +544,8 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
children: [
// Email Field
_buildEnhancedTextField(
label: 'Email Address',
hint: 'Enter your email address',
label: AppLocalizations.of(context)!.emailAddress,
hint: AppLocalizations.of(context)!.enterEmailAddress,
controller: _emailController,
focusNode: _emailFocusNode,
keyboardType: TextInputType.emailAddress,
@@ -554,12 +555,12 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
textInputAction: TextInputAction.done,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Email is required';
return AppLocalizations.of(context)!.emailRequired;
}
if (!RegExp(
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$')
.hasMatch(value)) {
return 'Please enter a valid email';
return AppLocalizations.of(context)!.validEmail;
}
return null;
},
@@ -847,7 +848,9 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
) ??
const TextStyle(),
child: Text(
isLoading ? 'Sending OTP...' : 'Send OTP',
isLoading
? AppLocalizations.of(context)!.sendingOtp
: AppLocalizations.of(context)!.sendOtp,
),
);
}
@@ -919,7 +922,7 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Already have an account? ",
'${AppLocalizations.of(context)!.alreadyHaveAccount} ',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey.shade700,
fontWeight: FontWeight.w500,
@@ -928,7 +931,7 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
'Back to Login',
AppLocalizations.of(context)!.backToLogin,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
@@ -982,8 +985,10 @@ class _GetOtpViewState extends State<GetOtpView> with TickerProviderStateMixin {
? Icons.info_outline
: (_isEmailValid ? Icons.check_circle : Icons.error_outline);
final msg = _emailController.text.isEmpty
? 'Enter your email address'
: (_isEmailValid ? 'Email looks good' : 'Invalid email address');
? AppLocalizations.of(context)!.enterEmailAddress
: (_isEmailValid
? AppLocalizations.of(context)!.emailLooksGood
: AppLocalizations.of(context)!.invalidEmailAddress);
return Container(
width: UIConstants.getResponsiveValue(
+16 -15
View File
@@ -7,6 +7,7 @@ import 'package:base_project/routes/route_names.dart';
import 'package:base_project/view_model/auth/auth_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../l10n/app_localizations.dart';
import '../../core/providers/dynamic_theme_provider.dart';
import '../../core/providers/theme_provider.dart';
@@ -497,7 +498,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
child: Column(
children: [
Text(
'Welcome Back!',
AppLocalizations.of(context)!.welcomeBack,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
@@ -507,7 +508,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
),
const SizedBox(height: UIConstants.spacing12),
Text(
'Sign in to continue to your account',
AppLocalizations.of(context)!.signInToContinue,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: colorScheme.onSurface.withOpacity(0.8),
fontWeight: FontWeight.w400,
@@ -557,8 +558,8 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
children: [
// Email Field
_buildEnhancedTextField(
label: 'Email Address',
hint: 'Enter your email',
label: AppLocalizations.of(context)!.emailAddress,
hint: AppLocalizations.of(context)!.enterYourEmail,
controller: _emailController,
focusNode: _emailFocusNode,
keyboardType: TextInputType.emailAddress,
@@ -569,11 +570,11 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
onSubmitted: (_) => _passwordFocusNode.requestFocus(),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Email is required';
return AppLocalizations.of(context)!.emailRequired;
}
if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$')
.hasMatch(value)) {
return 'Please enter a valid email';
return AppLocalizations.of(context)!.validEmail;
}
return null;
},
@@ -583,8 +584,8 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
// Password Field
_buildEnhancedTextField(
label: 'Password',
hint: 'Enter your password',
label: AppLocalizations.of(context)!.password,
hint: AppLocalizations.of(context)!.enterYourPassword,
controller: _passwordController,
focusNode: _passwordFocusNode,
obscureText: !_isPasswordVisible,
@@ -607,10 +608,10 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
textInputAction: TextInputAction.done,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Password is required';
return AppLocalizations.of(context)!.passwordRequired;
}
if (value.length < 6) {
return 'Password must be at least 6 characters';
return AppLocalizations.of(context)!.passwordMinLength;
}
return null;
},
@@ -727,7 +728,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
),
const SizedBox(width: UIConstants.spacing6),
Text(
'Forgot Password?',
AppLocalizations.of(context)!.forgotPassword,
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w600,
@@ -771,7 +772,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
child: Consumer<AuthViewModel>(
builder: (context, provider, child) {
return ModernButton(
text: 'Sign In',
text: AppLocalizations.of(context)!.signIn,
type: ModernButtonType.primary,
size: ModernButtonSize.large,
isLoading: provider.isLoading,
@@ -823,7 +824,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Don't have an account? ",
'${AppLocalizations.of(context)!.noAccount} ',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey.shade700,
fontWeight: FontWeight.w500,
@@ -834,7 +835,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
Navigator.pushNamed(context, RouteNames.getOtpView);
},
child: Text(
'Sign Up',
AppLocalizations.of(context)!.signUp,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
@@ -870,7 +871,7 @@ class _LoginViewState extends State<LoginView> with TickerProviderStateMixin {
padding: const EdgeInsets.symmetric(
horizontal: UIConstants.spacing16),
child: Text(
'Or continue with',
AppLocalizations.of(context)!.orContinueWith,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.white.withOpacity(0.9),
fontWeight: FontWeight.w500,
+2 -1
View File
@@ -1,5 +1,6 @@
import 'package:base_project/core/constants/ui_constants.dart';
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
import 'package:base_project/l10n/app_localizations.dart';
import 'package:base_project/routes/route_names.dart';
import 'package:base_project/shared/widgets/app_bar/modern_app_bar.dart';
import 'package:base_project/shared/widgets/buttons/modern_button.dart';
@@ -322,7 +323,7 @@ class _SignUpViewState extends State<SignUpView> with TickerProviderStateMixin {
Consumer<AuthViewModel>(
builder: (context, provider, child) {
return ModernButton(
text: 'Sign Up',
text: AppLocalizations.of(context)!.signUp,
type: ModernButtonType.primary,
size: ModernButtonSize.large,
isLoading: provider.isLoading,
+2 -1
View File
@@ -1,3 +1,4 @@
import 'package:base_project/l10n/app_localizations.dart';
import 'package:flutter/material.dart';
class SignupView extends StatelessWidget {
@@ -14,7 +15,7 @@ class SignupView extends StatelessWidget {
},
icon: Icon(Icons.adaptive.arrow_back),
),
title: const Text("SignUp"),
title: Text(AppLocalizations.of(context)!.signUp),
),
);
}
+10 -8
View File
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:pinput/pinput.dart';
import 'package:base_project/commans/widgets/custome_elevated_button.dart';
import 'package:provider/provider.dart';
import '../../l10n/app_localizations.dart';
import 'package:base_project/core/constants/ui_constants.dart';
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
@@ -83,7 +84,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
color: colorScheme.primary,
),
title: Text(
'Verify OTP',
AppLocalizations.of(context)!.verifyOtp,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
@@ -147,7 +148,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
),
const SizedBox(height: UIConstants.spacing16),
Text(
'Enter the 6-digit code sent to',
AppLocalizations.of(context)!.otpSentTo,
style: Theme.of(context)
.textTheme
.bodyMedium
@@ -157,7 +158,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
textAlign: TextAlign.center,
),
Text(
widget.email ?? 'your email',
widget.email ?? AppLocalizations.of(context)!.yourEmail,
style:
Theme.of(context).textTheme.titleMedium?.copyWith(
color: colorScheme.primary,
@@ -233,7 +234,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
onPressed: () async {
if (_otpController.text.length < 6) {
ToastMessageUtil.showToast(
message: 'Enter 6-digit OTP',
message: AppLocalizations.of(context)!.enterOtp,
toastType: ToastType.error,
);
return;
@@ -268,7 +269,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
);
}
},
child: const Text('Verify OTP'),
child: Text(AppLocalizations.of(context)!.verifyOtp),
),
],
);
@@ -285,8 +286,9 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
children: [
Text(
provider.isResendEnabled
? "Didn't receive code?"
: 'Resend in ${provider.start}s',
? AppLocalizations.of(context)!.didNotReceiveCode
: AppLocalizations.of(context)!
.resendIn(provider.start),
style: Theme.of(context)
.textTheme
.bodyMedium
@@ -304,7 +306,7 @@ class _VerifyOtpViewState extends State<VerifyOtpView>
}
: null,
child: Text(
'Resend',
AppLocalizations.of(context)!.resend,
style: TextStyle(
color: provider.isResendEnabled
? colorScheme.primary