Skip to content

Refactor enhance auth localization #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions lib/authentication/view/authentication_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,14 @@ import 'package:ht_dashboard/router/routes.dart';
import 'package:ht_dashboard/shared/constants/app_spacing.dart';

/// {@template authentication_page}
/// Displays authentication options (Google, Email, Anonymous) based on context.
/// Displays authentication options for the dashboard.
///
/// This page can be used for both initial sign-in and for connecting an
/// existing anonymous account.
/// This page provides a secure sign-in method for administrators and
/// publishers via email.
/// {@endtemplate}
class AuthenticationPage extends StatelessWidget {
/// {@macro authentication_page}
const AuthenticationPage({
required this.headline,
required this.subHeadline,
required this.showAnonymousButton,
super.key,
});

/// The main title displayed on the page.
final String headline;

/// The descriptive text displayed below the headline.
final String subHeadline;

/// Whether to show the "Continue Anonymously" button.
final bool showAnonymousButton;
const AuthenticationPage({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -88,15 +74,15 @@ class AuthenticationPage extends StatelessWidget {
// const SizedBox(height: AppSpacing.lg),
// --- Headline and Subheadline ---
Text(
headline,
l10n.authenticationPageHeadline,
style: textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: AppSpacing.md),
Text(
subHeadline,
l10n.authenticationPageSubheadline,
style: textTheme.bodyLarge?.copyWith(
color: colorScheme.onSurfaceVariant,
),
Expand Down
6 changes: 4 additions & 2 deletions lib/authentication/view/request_code_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:ht_dashboard/app/bloc/app_bloc.dart';
import 'package:ht_dashboard/app/config/config.dart';
import 'package:go_router/go_router.dart';
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
import 'package:ht_dashboard/l10n/l10n.dart';
import 'package:ht_dashboard/router/routes.dart';
Expand Down Expand Up @@ -137,7 +137,9 @@ class _RequestCodeView extends StatelessWidget {
builder: (context, environment) {
if (environment == AppEnvironment.demo) {
return Padding(
padding: const EdgeInsets.only(top: AppSpacing.lg),
padding: const EdgeInsets.only(
top: AppSpacing.lg,
),
child: Text(
l10n.demoEmailHint('[email protected]'),
style: textTheme.bodyMedium?.copyWith(
Expand Down
4 changes: 2 additions & 2 deletions lib/content_management/view/create_category_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class _CreateCategoryViewState extends State<_CreateCategoryView> {
SnackBar(content: Text(l10n.categoryCreatedSuccessfully)),
);
context.read<ContentManagementBloc>().add(
// Refresh the list to show the new category
const LoadCategoriesRequested(limit: kDefaultRowsPerPage),
// Refresh the list to show the new category
const LoadCategoriesRequested(limit: kDefaultRowsPerPage),
);
context.pop();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/content_management/view/create_headline_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class _CreateHeadlineViewState extends State<_CreateHeadlineView> {
SnackBar(content: Text(l10n.headlineCreatedSuccessfully)),
);
context.read<ContentManagementBloc>().add(
// Refresh the list to show the new headline
const LoadHeadlinesRequested(limit: kDefaultRowsPerPage),
// Refresh the list to show the new headline
const LoadHeadlinesRequested(limit: kDefaultRowsPerPage),
);
context.pop();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/content_management/view/create_source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
SnackBar(content: Text(l10n.sourceCreatedSuccessfully)),
);
context.read<ContentManagementBloc>().add(
// Refresh the list to show the new source
const LoadSourcesRequested(limit: kDefaultRowsPerPage),
// Refresh the list to show the new source
const LoadSourcesRequested(limit: kDefaultRowsPerPage),
);
context.pop();
}
Expand Down
18 changes: 15 additions & 3 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ abstract class AppLocalizations {
/// **'Hello World!'**
String get helloWorld;

/// Headline for the main authentication page
///
/// In en, this message translates to:
/// **'Dashboard Access'**
String get authenticationPageHeadline;

/// Subheadline for the main authentication page
///
/// In en, this message translates to:
/// **'Secure sign-in for administrators and publishers.'**
String get authenticationPageSubheadline;

/// Button label for signing in with email
///
/// In en, this message translates to:
Expand All @@ -113,19 +125,19 @@ abstract class AppLocalizations {
/// Title for the email sign-in page
///
/// In en, this message translates to:
/// **'Email Sign In'**
/// **'Secure Email Sign-In'**
String get emailSignInPageTitle;

/// Headline for the request code page
///
/// In en, this message translates to:
/// **'Sign in or create an account'**
/// **'Secure Email Sign-In'**
String get requestCodePageHeadline;

/// Subheadline for the request code page
///
/// In en, this message translates to:
/// **'Enter your email to receive a verification code. No password needed!'**
/// **'Enter your authorized email to receive a secure sign-in code.'**
String get requestCodePageSubheadline;

/// Label for the email input field on the request code page
Expand Down
13 changes: 10 additions & 3 deletions lib/l10n/app_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,26 @@ class AppLocalizationsAr extends AppLocalizations {
@override
String get helloWorld => 'مرحبا بالعالم!';

@override
String get authenticationPageHeadline => 'الوصول إلى لوحة التحكم';

@override
String get authenticationPageSubheadline =>
'تسجيل دخول آمن للمسؤولين والناشرين.';

@override
String get authenticationEmailSignInButton =>
'تسجيل الدخول بالبريد الإلكتروني';

@override
String get emailSignInPageTitle => 'تسجيل الدخول بالبريد الإلكتروني';
String get emailSignInPageTitle => 'تسجيل دخول آمن بالبريد الإلكتروني';

@override
String get requestCodePageHeadline => 'سجل الدخول أو أنشئ حسابًا';
String get requestCodePageHeadline => 'تسجيل دخول آمن بالبريد الإلكتروني';

@override
String get requestCodePageSubheadline =>
'أدخل بريدك الإلكتروني لتلقي رمز التحقق. لا حاجة لكلمة مرور!';
'أدخل بريدك الإلكتروني المعتمد لتلقي رمز تسجيل دخول آمن.';

@override
String get requestCodeEmailLabel => 'البريد الإلكتروني';
Expand Down
13 changes: 10 additions & 3 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get helloWorld => 'Hello World!';

@override
String get authenticationPageHeadline => 'Dashboard Access';

@override
String get authenticationPageSubheadline =>
'Secure sign-in for administrators and publishers.';

@override
String get authenticationEmailSignInButton => 'Sign in with Email';

@override
String get emailSignInPageTitle => 'Email Sign In';
String get emailSignInPageTitle => 'Secure Email Sign-In';

@override
String get requestCodePageHeadline => 'Sign in or create an account';
String get requestCodePageHeadline => 'Secure Email Sign-In';

@override
String get requestCodePageSubheadline =>
'Enter your email to receive a verification code. No password needed!';
'Enter your authorized email to receive a secure sign-in code.';

@override
String get requestCodeEmailLabel => 'Email';
Expand Down
14 changes: 11 additions & 3 deletions lib/l10n/arb/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
"@helloWorld": {
"description": "التحية التقليدية للمبرمج حديث الولادة"
},
"authenticationPageHeadline": "الوصول إلى لوحة التحكم",
"@authenticationPageHeadline": {
"description": "عنوان صفحة المصادقة الرئيسية"
},
"authenticationPageSubheadline": "تسجيل دخول آمن للمسؤولين والناشرين.",
"@authenticationPageSubheadline": {
"description": "عنوان فرعي لصفحة المصادقة الرئيسية"
},
"authenticationEmailSignInButton": "تسجيل الدخول بالبريد الإلكتروني",
"@authenticationEmailSignInButton": {
"description": "زر تسجيل الدخول بالبريد الإلكتروني"
},
"emailSignInPageTitle": "تسجيل الدخول بالبريد الإلكتروني",
"emailSignInPageTitle": "تسجيل دخول آمن بالبريد الإلكتروني",
"@emailSignInPageTitle": {
"description": "عنوان صفحة تسجيل الدخول بالبريد الإلكتروني"
},
"requestCodePageHeadline": "سجل الدخول أو أنشئ حسابًا",
"requestCodePageHeadline": "تسجيل دخول آمن بالبريد الإلكتروني",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The requestCodePageHeadline is identical to the emailSignInPageTitle, which can be redundant. A distinct, action-oriented translation, such as 'أدخل بريدك الإلكتروني' (Enter Your Email), would improve clarity.

  "requestCodePageHeadline": "أدخل بريدك الإلكتروني",

"@requestCodePageHeadline": {
"description": "عنوان صفحة طلب الرمز"
},
"requestCodePageSubheadline": "أدخل بريدك الإلكتروني لتلقي رمز التحقق. لا حاجة لكلمة مرور!",
"requestCodePageSubheadline": "أدخل بريدك الإلكتروني المعتمد لتلقي رمز تسجيل دخول آمن.",
"@requestCodePageSubheadline": {
"description": "عنوان فرعي لصفحة طلب الرمز"
},
Expand Down
14 changes: 11 additions & 3 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
},
"authenticationPageHeadline": "Dashboard Access",
"@authenticationPageHeadline": {
"description": "Headline for the main authentication page"
},
"authenticationPageSubheadline": "Secure sign-in for administrators and publishers.",
"@authenticationPageSubheadline": {
"description": "Subheadline for the main authentication page"
},
"authenticationEmailSignInButton": "Sign in with Email",
"@authenticationEmailSignInButton": {
"description": "Button label for signing in with email"
},
"emailSignInPageTitle": "Email Sign In",
"emailSignInPageTitle": "Secure Email Sign-In",
"@emailSignInPageTitle": {
"description": "Title for the email sign-in page"
},
"requestCodePageHeadline": "Sign in or create an account",
"requestCodePageHeadline": "Secure Email Sign-In",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The requestCodePageHeadline is identical to emailSignInPageTitle, which can be redundant. A distinct, action-oriented headline, such as 'Enter Your Email', would improve the user experience.

  "requestCodePageHeadline": "Enter Your Email",

"@requestCodePageHeadline": {
"description": "Headline for the request code page"
},
"requestCodePageSubheadline": "Enter your email to receive a verification code. No password needed!",
"requestCodePageSubheadline": "Enter your authorized email to receive a secure sign-in code.",
"@requestCodePageSubheadline": {
"description": "Subheadline for the request code page"
},
Expand Down
10 changes: 1 addition & 9 deletions lib/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,11 @@ GoRouter createRouter({
path: Routes.authentication,
name: Routes.authenticationName,
builder: (BuildContext context, GoRouterState state) {
const headline = 'Sign In to Dashboard';
const subHeadline = 'Enter your email to get a verification code.';
const showAnonymousButton = false;

return BlocProvider(
create: (context) => AuthenticationBloc(
authenticationRepository: context.read<HtAuthRepository>(),
),
child: const AuthenticationPage(
headline: headline,
subHeadline: subHeadline,
showAnonymousButton: showAnonymousButton,
),
child: const AuthenticationPage(),
);
},
routes: [
Expand Down
Loading