Skip to content
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

feat: Add i18n (FR language) + l10n (calendar + currency formatting) #20

Merged
merged 7 commits into from
Dec 13, 2022
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
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ SPEC CHECKSUMS:
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluttertoast: 74526702fea2c060ea55dde75895b7e1bde1c86b
fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0
google_mlkit_barcode_scanning: 4805cc8281f41915a13f8bbb7223291e982b6836
google_mlkit_commons: e9070f57232c3a3e4bd42fdfa621bb1f4bb3e709
google_mlkit_entity_extraction: 19d5b9c2f5049b2145747bbc8c7601b5b7e71e56
Expand Down
3 changes: 3 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
38 changes: 21 additions & 17 deletions lib/app/settings.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,33 @@ mixin _$VoucherVaultSettings {
abstract class $VoucherVaultSettingsCopyWith<$Res> {
factory $VoucherVaultSettingsCopyWith(VoucherVaultSettings value,
$Res Function(VoucherVaultSettings) then) =
_$VoucherVaultSettingsCopyWithImpl<$Res>;
_$VoucherVaultSettingsCopyWithImpl<$Res, VoucherVaultSettings>;
@useResult
$Res call({bool smartScan});
}

/// @nodoc
class _$VoucherVaultSettingsCopyWithImpl<$Res>
class _$VoucherVaultSettingsCopyWithImpl<$Res,
$Val extends VoucherVaultSettings>
implements $VoucherVaultSettingsCopyWith<$Res> {
_$VoucherVaultSettingsCopyWithImpl(this._value, this._then);

final VoucherVaultSettings _value;
// ignore: unused_field
final $Res Function(VoucherVaultSettings) _then;
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? smartScan = freezed,
Object? smartScan = null,
}) {
return _then(_value.copyWith(
smartScan: smartScan == freezed
smartScan: null == smartScan
? _value.smartScan
: smartScan // ignore: cast_nullable_to_non_nullable
as bool,
));
) as $Val);
}
}

Expand All @@ -65,26 +69,25 @@ abstract class _$$_VoucherVaultSettingsCopyWith<$Res>
$Res Function(_$_VoucherVaultSettings) then) =
__$$_VoucherVaultSettingsCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool smartScan});
}

/// @nodoc
class __$$_VoucherVaultSettingsCopyWithImpl<$Res>
extends _$VoucherVaultSettingsCopyWithImpl<$Res>
extends _$VoucherVaultSettingsCopyWithImpl<$Res, _$_VoucherVaultSettings>
implements _$$_VoucherVaultSettingsCopyWith<$Res> {
__$$_VoucherVaultSettingsCopyWithImpl(_$_VoucherVaultSettings _value,
$Res Function(_$_VoucherVaultSettings) _then)
: super(_value, (v) => _then(v as _$_VoucherVaultSettings));

@override
_$_VoucherVaultSettings get _value => super._value as _$_VoucherVaultSettings;
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? smartScan = freezed,
Object? smartScan = null,
}) {
return _then(_$_VoucherVaultSettings(
smartScan: smartScan == freezed
smartScan: null == smartScan
? _value.smartScan
: smartScan // ignore: cast_nullable_to_non_nullable
as bool,
Expand Down Expand Up @@ -114,16 +117,17 @@ class _$_VoucherVaultSettings implements _VoucherVaultSettings {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_VoucherVaultSettings &&
const DeepCollectionEquality().equals(other.smartScan, smartScan));
(identical(other.smartScan, smartScan) ||
other.smartScan == smartScan));
}

@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, const DeepCollectionEquality().hash(smartScan));
int get hashCode => Object.hash(runtimeType, smartScan);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_VoucherVaultSettingsCopyWith<_$_VoucherVaultSettings> get copyWith =>
__$$_VoucherVaultSettingsCopyWithImpl<_$_VoucherVaultSettings>(
this, _$identity);
Expand Down
7 changes: 7 additions & 0 deletions lib/app/voucher_vault_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:vouchervault/app/app.dart';
import 'package:vouchervault/auth/auth.dart';
import 'package:vouchervault/vouchers/vouchers.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

part 'voucher_vault_app.g.dart';

Expand Down Expand Up @@ -41,7 +43,12 @@ Widget __app() => AtomBuilder((context, watch, child) {
),
navigatorObservers: [routeObserver],
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
FormBuilderLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
);
});
61 changes: 30 additions & 31 deletions lib/auth/model.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ mixin _$AuthState {
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? unauthenticated,
TResult Function(AuthenticatedReason reason)? authenticated,
TResult? Function()? unauthenticated,
TResult? Function(AuthenticatedReason reason)? authenticated,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
Expand All @@ -56,8 +56,8 @@ mixin _$AuthState {
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(Unauthenticated value)? unauthenticated,
TResult Function(Authenticated value)? authenticated,
TResult? Function(Unauthenticated value)? unauthenticated,
TResult? Function(Authenticated value)? authenticated,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
Expand All @@ -73,16 +73,18 @@ mixin _$AuthState {
/// @nodoc
abstract class $AuthStateCopyWith<$Res> {
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) =
_$AuthStateCopyWithImpl<$Res>;
_$AuthStateCopyWithImpl<$Res, AuthState>;
}

/// @nodoc
class _$AuthStateCopyWithImpl<$Res> implements $AuthStateCopyWith<$Res> {
class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState>
implements $AuthStateCopyWith<$Res> {
_$AuthStateCopyWithImpl(this._value, this._then);

final AuthState _value;
// ignore: unused_field
final $Res Function(AuthState) _then;
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
}

/// @nodoc
Expand All @@ -94,14 +96,11 @@ abstract class _$$UnauthenticatedCopyWith<$Res> {

/// @nodoc
class __$$UnauthenticatedCopyWithImpl<$Res>
extends _$AuthStateCopyWithImpl<$Res>
extends _$AuthStateCopyWithImpl<$Res, _$Unauthenticated>
implements _$$UnauthenticatedCopyWith<$Res> {
__$$UnauthenticatedCopyWithImpl(
_$Unauthenticated _value, $Res Function(_$Unauthenticated) _then)
: super(_value, (v) => _then(v as _$Unauthenticated));

@override
_$Unauthenticated get _value => super._value as _$Unauthenticated;
: super(_value, _then);
}

/// @nodoc
Expand Down Expand Up @@ -144,8 +143,8 @@ class _$Unauthenticated extends Unauthenticated {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? unauthenticated,
TResult Function(AuthenticatedReason reason)? authenticated,
TResult? Function()? unauthenticated,
TResult? Function(AuthenticatedReason reason)? authenticated,
}) {
return unauthenticated?.call();
}
Expand Down Expand Up @@ -175,8 +174,8 @@ class _$Unauthenticated extends Unauthenticated {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(Unauthenticated value)? unauthenticated,
TResult Function(Authenticated value)? authenticated,
TResult? Function(Unauthenticated value)? unauthenticated,
TResult? Function(Authenticated value)? authenticated,
}) {
return unauthenticated?.call(this);
}
Expand Down Expand Up @@ -215,25 +214,25 @@ abstract class _$$AuthenticatedCopyWith<$Res> {
factory _$$AuthenticatedCopyWith(
_$Authenticated value, $Res Function(_$Authenticated) then) =
__$$AuthenticatedCopyWithImpl<$Res>;
@useResult
$Res call({AuthenticatedReason reason});
}

/// @nodoc
class __$$AuthenticatedCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
class __$$AuthenticatedCopyWithImpl<$Res>
extends _$AuthStateCopyWithImpl<$Res, _$Authenticated>
implements _$$AuthenticatedCopyWith<$Res> {
__$$AuthenticatedCopyWithImpl(
_$Authenticated _value, $Res Function(_$Authenticated) _then)
: super(_value, (v) => _then(v as _$Authenticated));

@override
_$Authenticated get _value => super._value as _$Authenticated;
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? reason = freezed,
Object? reason = null,
}) {
return _then(_$Authenticated(
reason == freezed
null == reason
? _value.reason
: reason // ignore: cast_nullable_to_non_nullable
as AuthenticatedReason,
Expand Down Expand Up @@ -267,16 +266,16 @@ class _$Authenticated extends Authenticated {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$Authenticated &&
const DeepCollectionEquality().equals(other.reason, reason));
(identical(other.reason, reason) || other.reason == reason));
}

@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, const DeepCollectionEquality().hash(reason));
int get hashCode => Object.hash(runtimeType, reason);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$AuthenticatedCopyWith<_$Authenticated> get copyWith =>
__$$AuthenticatedCopyWithImpl<_$Authenticated>(this, _$identity);

Expand All @@ -292,8 +291,8 @@ class _$Authenticated extends Authenticated {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? unauthenticated,
TResult Function(AuthenticatedReason reason)? authenticated,
TResult? Function()? unauthenticated,
TResult? Function(AuthenticatedReason reason)? authenticated,
}) {
return authenticated?.call(reason);
}
Expand Down Expand Up @@ -323,8 +322,8 @@ class _$Authenticated extends Authenticated {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(Unauthenticated value)? unauthenticated,
TResult Function(Authenticated value)? authenticated,
TResult? Function(Unauthenticated value)? unauthenticated,
TResult? Function(Authenticated value)? authenticated,
}) {
return authenticated?.call(this);
}
Expand Down
28 changes: 28 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"vouchers": "Vouchers",
"edit": "Edit",
"close": "Close",
"copiedToClipboard": "Copied to clipboard",
"areYouSure": "Are you sure?",
"confirmRemoveVoucher": "That you want to remove this voucher?",
"cancel": "Cancel",
"remove": "Remove",
"howMuchSpend": "How much did you spend?",
"amount": "Amount",
"ok": "OK",
"addVoucher": "Add voucher",
"editVoucher": "Edit voucher",
"create": "Create",
"update": "Update",
"scanBarcode": "Scan barcode",
"description": "Description",
"code": "Code",
"expires": "Expires",
"removeOnceExpired": "Remove once expired",
"balance": "Balance",
"notes": "Notes",
"import": "Import",
"export": "Export",
"appLock": "App lock",
"smartScan": "Smart scan"
}
24 changes: 24 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"vouchers": "Mes bons",
"edit": "Modifier",
"close": "Fermer",
"copiedToClipboard": "Copié dans le presse-papier",
"areYouSure": "Etes-vous sûr?",
"confirmRemoveVoucher": "De vouloir supprimer ce bon?",
"cancel": "Annuler",
"remove": "Supprimer",
"howMuchSpend": "Quel montant avez-vous depensé?",
"amount": "Montant",
"ok": "Valider",
"addVoucher": "Ajouter un bon",
"editVoucher": "Modifier ce bon",
"create": "Créer",
"update": "Modifier",
"scanBarcode": "Scanner un code barre",
"description": "Description",
"code": "Code",
"expires": "Date d'expiration",
"removeOnceExpired": "Supprimer une fois expiré",
"balance": "Solde",
"notes": "Notes"
}
8 changes: 6 additions & 2 deletions lib/shared/voucher_details/voucher_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:vouchervault/app/app.dart';
import 'package:vouchervault/lib/lib.dart';
import 'package:vouchervault/vouchers/models/voucher.dart';
import 'package:intl/intl.dart';

part 'voucher_details.g.dart';

final formatCurrency = NumberFormat.simpleCurrency();

List<Widget> buildVoucherDetails(
BuildContext context,
Voucher voucher, {
Color textColor = Colors.white,
Option<double> space = const None(),
bool includeNotes = false,
}) =>

intersperse<Widget>(SizedBox(
height: space.p(O.getOrElse(() => AppTheme.space1)),
))([
Expand All @@ -25,11 +29,11 @@ List<Widget> buildVoucherDetails(
formatExpires(dt),
)
])),
...voucher.balanceOption.p(O.map(millisToString)).p(ifSomeList((b) => [
...voucher.balanceDoubleOption.p(ifSomeList((b) => [
_VoucherDetailRow(
textColor,
Icons.account_balance,
'\$$b',
formatCurrency.format(b),
),
])),
...voucher.notesOption
Expand Down
Loading