add locale to app using intl
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
||||
import 'package:thingsboard_app/constants/assets_path.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
|
||||
import 'package:thingsboard_app/generated/l10n.dart';
|
||||
import 'package:thingsboard_app/widgets/tb_progress_indicator.dart';
|
||||
import 'package:thingsboard_client/thingsboard_client.dart';
|
||||
|
||||
@@ -73,14 +74,14 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
SvgPicture.asset(ThingsboardImage.thingsBoardWithTitle,
|
||||
height: 25,
|
||||
color: Theme.of(context).primaryColor,
|
||||
semanticsLabel: 'ThingsBoard Logo')
|
||||
semanticsLabel: '${S.of(context).logoDefaultValue}')
|
||||
]
|
||||
),
|
||||
SizedBox(height: 32),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'Login to your account',
|
||||
'${S.of(context).loginNotification}',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 28,
|
||||
@@ -98,7 +99,7 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
Flexible(child: Divider()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text('OR'),
|
||||
child: Text('${S.of(context).OR}'),
|
||||
),
|
||||
Flexible(child: Divider())
|
||||
],
|
||||
@@ -113,12 +114,12 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
FormBuilderTextField(
|
||||
name: 'username',
|
||||
validator: FormBuilderValidators.compose([
|
||||
FormBuilderValidators.required(context, errorText: 'Email is required.'),
|
||||
FormBuilderValidators.email(context, errorText: 'Invalid email format.')
|
||||
FormBuilderValidators.required(context, errorText: '${S.of(context).emailRequireText}'),
|
||||
FormBuilderValidators.email(context, errorText: '${S.of(context).emailInvalidText}')
|
||||
]),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Email'
|
||||
labelText: '${S.of(context).email}'
|
||||
),
|
||||
),
|
||||
SizedBox(height: 28),
|
||||
@@ -129,7 +130,7 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
name: 'password',
|
||||
obscureText: !showPassword,
|
||||
validator: FormBuilderValidators.compose([
|
||||
FormBuilderValidators.required(context, errorText: 'Password is required.')
|
||||
FormBuilderValidators.required(context, errorText: '${S.of(context).passwordRequireText}')
|
||||
]),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
@@ -139,7 +140,7 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
},
|
||||
),
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Password'
|
||||
labelText: '${S.of(context).password}'
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -155,7 +156,7 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
_forgotPassword();
|
||||
},
|
||||
child: Text(
|
||||
'Forgot Password?',
|
||||
'${S.of(context).passwordForgotText}',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.primary,
|
||||
letterSpacing: 1,
|
||||
fontSize: 12,
|
||||
@@ -166,7 +167,7 @@ class _LoginPageState extends TbPageState<LoginPage> {
|
||||
),
|
||||
Spacer(),
|
||||
ElevatedButton(
|
||||
child: Text('Log In'),
|
||||
child: Text('${S.of(context).login}'),
|
||||
style: ElevatedButton.styleFrom(padding: EdgeInsets.symmetric(vertical: 16)),
|
||||
onPressed: () {
|
||||
_login();
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:thingsboard_app/core/auth/login/login_page_background.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
|
||||
import 'package:thingsboard_app/generated/l10n.dart';
|
||||
import 'package:thingsboard_app/widgets/tb_app_bar.dart';
|
||||
import 'package:thingsboard_app/widgets/tb_progress_indicator.dart';
|
||||
|
||||
@@ -33,7 +34,7 @@ class _ResetPasswordRequestPageState extends TbPageState<ResetPasswordRequestPag
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: TbAppBar(
|
||||
tbContext,
|
||||
title: Text('Reset password'),
|
||||
title: Text('${S.of(context).passwordReset}'),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
@@ -47,7 +48,7 @@ class _ResetPasswordRequestPageState extends TbPageState<ResetPasswordRequestPag
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 16),
|
||||
Text('Enter the email associated with your account and we\'ll send an email with password reset link',
|
||||
Text('${S.of(context).passwordResetText}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFAFAFAF),
|
||||
@@ -57,20 +58,20 @@ class _ResetPasswordRequestPageState extends TbPageState<ResetPasswordRequestPag
|
||||
),
|
||||
SizedBox(height: 61),
|
||||
FormBuilderTextField(
|
||||
name: 'email',
|
||||
name: '${S.of(context).email}',
|
||||
autofocus: true,
|
||||
validator: FormBuilderValidators.compose([
|
||||
FormBuilderValidators.required(context, errorText: 'Email is required.'),
|
||||
FormBuilderValidators.email(context, errorText: 'Invalid email format.')
|
||||
FormBuilderValidators.required(context, errorText: '${S.of(context).emailRequireText}'),
|
||||
FormBuilderValidators.email(context, errorText: '${S.of(context).emailInvalidText}')
|
||||
]),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Email *'
|
||||
labelText: '${S.of(context).email} *'
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
ElevatedButton(
|
||||
child: Text('Request password reset'),
|
||||
child: Text('${S.of(context).requestPasswordReset}'),
|
||||
style: ElevatedButton.styleFrom(padding: EdgeInsets.symmetric(vertical: 16)),
|
||||
onPressed: () {
|
||||
_requestPasswordReset();
|
||||
@@ -114,7 +115,7 @@ class _ResetPasswordRequestPageState extends TbPageState<ResetPasswordRequestPag
|
||||
await Future.delayed(Duration(milliseconds: 300));
|
||||
await tbClient.sendResetPasswordLink(email);
|
||||
_isLoadingNotifier.value = false;
|
||||
showSuccessNotification('Password reset link was successfully sent!');
|
||||
showSuccessNotification('${S.of(context).passwordResetLinkSuccessfullySentNotification}');
|
||||
} catch(e) {
|
||||
_isLoadingNotifier.value = false;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context.dart';
|
||||
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
|
||||
import 'package:thingsboard_app/generated/l10n.dart';
|
||||
import 'package:thingsboard_app/utils/utils.dart';
|
||||
import 'package:thingsboard_client/thingsboard_client.dart';
|
||||
|
||||
@@ -55,15 +56,15 @@ mixin EntitiesBase<T, P> on HasTbContext {
|
||||
Key? getKey(T entity) => null;
|
||||
|
||||
Widget buildEntityListCard(BuildContext context, T entity) {
|
||||
return Text('Not implemented!');
|
||||
return Text('${S.of(context).notImplemented}');
|
||||
}
|
||||
|
||||
Widget buildEntityListWidgetCard(BuildContext context, T entity) {
|
||||
return Text('Not implemented!');
|
||||
return Text('${S.of(context).notImplemented}');
|
||||
}
|
||||
|
||||
Widget buildEntityGridCard(BuildContext context, T entity) {
|
||||
return Text('Not implemented!');
|
||||
return Text('${S.of(context).notImplemented}');
|
||||
}
|
||||
|
||||
double? gridChildAspectRatio() => null;
|
||||
@@ -352,7 +353,7 @@ abstract class BaseEntitiesState<T, P> extends TbContextState<BaseEntitiesWidget
|
||||
Widget noItemsFoundIndicatorBuilder(BuildContext context) {
|
||||
return FirstPageExceptionIndicator(
|
||||
title: widget.noItemsFoundText,
|
||||
message: 'The list is currently empty.',
|
||||
message: '${S.of(context).listIsEmptyText}',
|
||||
onTryAgain: widget.searchMode ? null : () => pagingController.refresh(),
|
||||
);
|
||||
}
|
||||
@@ -407,8 +408,8 @@ class FirstPageExceptionIndicator extends StatelessWidget {
|
||||
Icons.refresh,
|
||||
color: Colors.white,
|
||||
),
|
||||
label: const Text(
|
||||
'Try Again',
|
||||
label: Text(
|
||||
'${S.of(context).tryAgain}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
|
||||
Reference in New Issue
Block a user