Skip to content

Commit

Permalink
migrating localizaition_package from flutter_localization to flutter_…
Browse files Browse the repository at this point in the history
…intl (#98)

* migrate from flutter_localizations to flutter_intls
  • Loading branch information
SankethBK authored Oct 21, 2023
1 parent ebf0d68 commit 8098795
Show file tree
Hide file tree
Showing 66 changed files with 3,297 additions and 752 deletions.
4 changes: 2 additions & 2 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
arb-dir: lib/l10n/arb
template-arb-file: app_en.arb
arb-dir: lib/l10n/
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false
4 changes: 2 additions & 2 deletions lib/app/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:dairy_app/core/pages/settings_page.dart';
import 'package:dairy_app/features/auth/presentation/pages/auth_page.dart';
import 'package:dairy_app/features/notes/presentation/pages/note_create_page.dart';
import 'package:dairy_app/features/notes/presentation/pages/note_read_only_page.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) {
Expand Down Expand Up @@ -35,7 +35,7 @@ class RouteGenerator {

return MaterialPageRoute(
builder: (context) => Center(
child: Text(AppLocalizations.of(context).pageNotFound),
child: Text(S.current.pageNotFound),
),
);
}
Expand Down
17 changes: 3 additions & 14 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:dairy_app/features/notes/presentation/bloc/notes/notes_bloc.dart
import 'package:dairy_app/features/notes/presentation/bloc/notes_fetch/notes_fetch_cubit.dart';
import 'package:dairy_app/features/notes/presentation/bloc/selectable_list/selectable_list_cubit.dart';
import 'package:dairy_app/features/sync/presentation/bloc/notes_sync/notesync_cubit.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

final log = printer("App");
Expand Down Expand Up @@ -107,20 +107,9 @@ class _AppViewState extends State<AppView> {
navigatorKey: _navigatorKey,
debugShowCheckedModeBanner: false,
title: "My Dairy",
supportedLocales: const [
Locale('en'),
Locale('hi'),
Locale('pa'),
Locale('he'),
Locale('kn'),
Locale('pt', "BR"),
Locale('sw'),
Locale('ar'),
Locale('de'),
Locale('fi')
],
supportedLocales: S.delegate.supportedLocales,
localizationsDelegates: const [
AppLocalizations.delegate,
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
Expand Down
4 changes: 2 additions & 2 deletions lib/core/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import 'package:dairy_app/features/auth/presentation/widgets/security_settings.d
import 'package:dairy_app/features/auth/presentation/widgets/setup_account.dart';
import 'package:dairy_app/features/notes/presentation/widgets/daily_reminders.dart';
import 'package:dairy_app/features/sync/presentation/widgets/sync_settings.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../widgets/auto_save_enable.dart';

class SettingsPage extends StatefulWidget {
Expand Down Expand Up @@ -73,7 +73,7 @@ class _SettingsPageState extends State<SettingsPage> {
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.arrow_back),
),
title: Text(AppLocalizations.of(context).settings),
title: Text(S.current.settings),
actions: [LogoutButton(authSessionBloc: authSessionBloc)],
),
body: Container(
Expand Down
12 changes: 6 additions & 6 deletions lib/core/widgets/auto_save_enable.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../../app/themes/theme_extensions/settings_page_theme_extensions.dart';
import '../../features/auth/core/constants.dart';
import '../../features/auth/presentation/bloc/user_config/user_config_cubit.dart';
import '../utils/utils.dart';
import 'package:dairy_app/app/themes/theme_extensions/settings_page_theme_extensions.dart';
import 'package:dairy_app/features/auth/core/constants.dart';
import 'package:dairy_app/features/auth/presentation/bloc/user_config/user_config_cubit.dart';
import 'package:dairy_app/core/utils/utils.dart';

class AutoSaveToggleButton extends StatelessWidget {
const AutoSaveToggleButton({Key? key}) : super(key: key);
Expand All @@ -32,7 +32,7 @@ class AutoSaveToggleButton extends StatelessWidget {
activeColor: activeColor,
contentPadding: const EdgeInsets.all(0.0),
title: Text(
AppLocalizations.of(context).enableAutoSave,
S.current.enableAutoSave,
style: TextStyle(color: mainTextColor),
),
subtitle: Text(
Expand Down
16 changes: 8 additions & 8 deletions lib/core/widgets/home_page_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'package:dairy_app/core/widgets/submit_button.dart';
import 'package:dairy_app/features/notes/presentation/bloc/notes/notes_bloc.dart';
import 'package:dairy_app/features/notes/presentation/bloc/notes_fetch/notes_fetch_cubit.dart';
import 'package:dairy_app/features/notes/presentation/bloc/selectable_list/selectable_list_cubit.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class HomePageAppBar extends StatefulWidget implements PreferredSizeWidget {
const HomePageAppBar({
Expand Down Expand Up @@ -296,7 +296,7 @@ class Title extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
AppLocalizations.of(context).dateFilter,
S.current.dateFilter,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
Expand All @@ -310,7 +310,7 @@ class Title extends StatelessWidget {
Flexible(
flex: 2,
child: Text(
AppLocalizations.of(context).from,
S.current.from,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
Expand All @@ -334,7 +334,7 @@ class Title extends StatelessWidget {
Flexible(
flex: 2,
child: Text(
AppLocalizations.of(context).to,
S.current.to,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
Expand All @@ -355,7 +355,7 @@ class Title extends StatelessWidget {
SubmitButton(
isLoading: false,
onSubmitted: () => Navigator.of(context).pop(),
buttonText: AppLocalizations.of(context).done,
buttonText: S.current.done,
)
],
),
Expand Down Expand Up @@ -407,7 +407,7 @@ class _DeleteButton extends StatelessWidget {
noteList: selectableListCubit.state.selectedItems));
}
},
buttonText: AppLocalizations.of(context).delete);
buttonText: S.current.delete);
},
);
}
Expand All @@ -423,7 +423,7 @@ class _CancelButton extends StatelessWidget {
return BlocBuilder<NotesBloc, NotesState>(
builder: (context, state) {
return CancelButton(
buttonText: AppLocalizations.of(context).cancel,
buttonText: S.current.cancel,
onPressed: () {
if (state is NoteDeleteLoading) {
return;
Expand Down Expand Up @@ -509,7 +509,7 @@ class DeleteIcon extends StatelessWidget {
showToast(
"$deletionCount item${deletionCount > 1 ? "s" : ""} deleted");
} else {
showToast(AppLocalizations.of(context).deletionFailed);
showToast(S.current.deletionFailed);
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/logout_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:dairy_app/core/widgets/cancel_button.dart';
import 'package:dairy_app/core/widgets/glass_dialog.dart';
import 'package:dairy_app/core/widgets/submit_button.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class LogoutButton extends StatelessWidget {
const LogoutButton({
Expand Down Expand Up @@ -34,7 +34,7 @@ class LogoutButton extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
AppLocalizations.of(context).areYouSureAboutLoggingOut,
S.current.areYouSureAboutLoggingOut,
style: TextStyle(fontSize: 16.0, color: mainTextColor),
),
const SizedBox(height: 15),
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/send_feedback.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

Expand All @@ -14,7 +14,7 @@ class SendFeedBack extends StatelessWidget {
Widget build(BuildContext context) => SettingsTile(
onTap: _launchEmailApp,
child: Text(
AppLocalizations.of(context).sendFeedback,
S.current.sendFeedback,
style: TextStyle(
fontSize: 16.0,
color: Theme.of(context)
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/share_with_friends.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class ShareWithFriends extends StatelessWidget {
const ShareWithFriends({Key? key}) : super(key: key);
Expand Down Expand Up @@ -31,7 +31,7 @@ class ShareWithFriends extends StatelessWidget {
}
}),
child: Text(
AppLocalizations.of(context).shareWithFriends,
S.current.shareWithFriends,
style: mainTextStyle,
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/theme_dropdown.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/app/themes/theme_extensions/settings_page_theme_extensions.dart';
import 'package:dairy_app/features/auth/presentation/bloc/cubit/theme_cubit.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class ThemeDropdown extends StatelessWidget {
const ThemeDropdown({Key? key}) : super(key: key);
Expand All @@ -23,7 +23,7 @@ class ThemeDropdown extends StatelessWidget {
return Row(
children: [
Text(
AppLocalizations.of(context).chooseTheme,
S.current.chooseTheme,
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/version_number.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class VersionNumber extends StatelessWidget {
const VersionNumber({Key? key}) : super(key: key);
Expand All @@ -25,7 +25,7 @@ class VersionNumber extends StatelessWidget {
child: Row(
children: [
Text(
AppLocalizations.of(context).appVersion,
S.current.appVersion,
style: mainTextStyle,
),
const Spacer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:dairy_app/features/auth/data/models/user_config_model.dart';
import 'package:dairy_app/features/auth/domain/repositories/authentication_repository.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart';
import 'package:dairy_app/features/sync/data/datasources/temeplates/key_value_data_source_template.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

final log = printer("FingerPrintAuthRepo");

Expand Down Expand Up @@ -88,7 +88,7 @@ class FingerPrintAuthRepository {

result.fold((e) {
log.e(e);
showToast(AppLocalizations.of(context).fingerprintLoginFailed);
showToast(S.current.fingerprintLoginFailed);
}, (user) {
// for fingerprint login, it's never fresh login
//! since a feature is removed, freshlogin is true to avoid breaking changes
Expand All @@ -98,7 +98,7 @@ class FingerPrintAuthRepository {
});
} else {
log.e("lastLoginUser not found");
showToast(AppLocalizations.of(context).fingerprintLoginFailed);
showToast(S.current.fingerprintLoginFailed);
}
} else if (value == FingerPrintAuthState.platformError) {
fingerPrintAuthStreamSubscription?.cancel();
Expand All @@ -107,7 +107,7 @@ class FingerPrintAuthRepository {
fingerPrintAuthStreamSubscription?.cancel();
isFingerPrintAuthActivated = false;

showToast(AppLocalizations.of(context).tooManyWrongAttempts);
showToast(S.current.tooManyWrongAttempts);
} else if (value == FingerPrintAuthState.fail) {
// showToast("fingerprint not recognized");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:dairy_app/core/widgets/glass_dialog.dart';
import 'package:dairy_app/core/widgets/submit_button.dart';
import 'package:dairy_app/features/auth/core/failures/failures.dart';
import 'package:dairy_app/features/auth/presentation/widgets/email_input_field.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Future<dynamic> emailChangePopup(
BuildContext context, Function(String) submitEmailChange) {
Expand All @@ -24,7 +24,7 @@ Future<dynamic> emailChangePopup(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(AppLocalizations.of(context).enterNewEmail,
Text(S.current.enterNewEmail,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -58,13 +58,12 @@ Future<dynamic> emailChangePopup(
setState(() {
isLoading = false;
});
showToast(
AppLocalizations.of(context).emailUpdatedSuccessfully);
showToast(S.current.emailUpdatedSuccessfully);
await Future.delayed(const Duration(milliseconds: 500));
Navigator.of(context).pop(true);
});
},
buttonText: AppLocalizations.of(context).submit,
buttonText: S.current.submit,
);
})
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:dairy_app/core/widgets/glass_dialog.dart';
import 'package:dairy_app/core/widgets/submit_button.dart';
import 'package:dairy_app/features/auth/core/failures/failures.dart';
import 'package:dairy_app/features/auth/presentation/widgets/email_input_field.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Future<void> forgotPasswordPopup(
BuildContext context, Function(String) submitForgotPassword) {
Expand All @@ -24,7 +24,7 @@ Future<void> forgotPasswordPopup(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(AppLocalizations.of(context).enterRegisteredEmail,
Text(S.current.enterRegisteredEmail,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -58,11 +58,11 @@ Future<void> forgotPasswordPopup(
setState(() {
isLoading = false;
});
showToast(AppLocalizations.of(context).passwordResetMailSent);
showToast(S.current.passwordResetMailSent);
Navigator.of(context).pop();
});
},
buttonText: AppLocalizations.of(context).submit,
buttonText: S.current.submit,
);
})
],
Expand Down
4 changes: 2 additions & 2 deletions lib/features/auth/presentation/widgets/guest_sign_up.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:dairy_app/app/themes/theme_extensions/auth_page_theme_extensions
import 'package:dairy_app/features/auth/core/constants.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_form/auth_form_bloc.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart';
import 'package:dairy_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class GuestSignUp extends StatelessWidget {
const GuestSignUp({Key? key}) : super(key: key);
Expand All @@ -28,7 +28,7 @@ class GuestSignUp extends StatelessWidget {
authFormbloc.add(AuthFormGuestSignIn());
},
child: Text(
AppLocalizations.of(context).continueAsGues,
S.current.continueAsGues,
style: TextStyle(
color: linkColor,
fontWeight: FontWeight.bold,
Expand Down
Loading

0 comments on commit 8098795

Please sign in to comment.