feat: Migrated strings, and translations to native flutter l10n plugin

This commit is contained in:
Anton Stubenbord
2023-02-17 00:00:13 +01:00
parent 7b55a96164
commit 14ab604118
90 changed files with 1661 additions and 683 deletions

View File

@@ -220,7 +220,7 @@ class DefaultAdaptiveDocumentsView extends AdaptiveDocumentsView {
Widget _buildListView() {
if (showLoadingPlaceholder) {
return DocumentsListLoadingWidget();
return const DocumentsListLoadingWidget();
}
return ListView.builder(

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class DeleteDocumentConfirmationDialog extends StatelessWidget {
final DocumentModel document;
@@ -9,12 +9,12 @@ class DeleteDocumentConfirmationDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(S.of(context).confirmDeletion),
title: Text(S.of(context)!.confirmDeletion),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
S.of(context).areYouSureYouWantToDeleteTheFollowingDocuments(1),
S.of(context)!.areYouSureYouWantToDeleteTheFollowingDocuments(1),
),
const SizedBox(height: 16),
Text(
@@ -26,13 +26,13 @@ class DeleteDocumentConfirmationDialog extends StatelessWidget {
),
),
const SizedBox(height: 16),
Text(S.of(context).thisActionIsIrreversibleDoYouWishToProceedAnyway),
Text(S.of(context)!.thisActionIsIrreversibleDoYouWishToProceedAnyway),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: Text(S.of(context).cancel),
child: Text(S.of(context)!.cancel),
),
TextButton(
style: ButtonStyle(
@@ -42,7 +42,7 @@ class DeleteDocumentConfirmationDialog extends StatelessWidget {
onPressed: () {
Navigator.pop(context, true);
},
child: Text(S.of(context).delete),
child: Text(S.of(context)!.delete),
),
],
);

View File

@@ -3,7 +3,7 @@ import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/widgets/empty_state.dart';
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
import 'package:paperless_mobile/features/paged_document_view/cubit/paged_documents_state.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class DocumentsEmptyState extends StatelessWidget {
final DocumentPagingState state;
@@ -18,13 +18,13 @@ class DocumentsEmptyState extends StatelessWidget {
Widget build(BuildContext context) {
return Center(
child: EmptyState(
title: S.of(context).oops,
subtitle: S.of(context).thereSeemsToBeNothingHere,
title: S.of(context)!.oops,
subtitle: S.of(context)!.thereSeemsToBeNothingHere,
bottomChild: state.filter != DocumentFilter.initial && onReset != null
? TextButton(
onPressed: onReset,
child: Text(
S.of(context).resetFilter,
S.of(context)!.resetFilter,
),
).padded()
: null,

View File

@@ -19,6 +19,7 @@ class DocumentsListLoadingWidget extends StatelessWidget {
);
} else {
return ListView.builder(
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => _buildFakeListItem(context),
);

View File

@@ -6,7 +6,7 @@ import 'package:paperless_mobile/core/widgets/form_builder_fields/extended_date_
import 'package:paperless_mobile/features/labels/cubit/label_cubit.dart';
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_form_field.dart';
import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
import 'text_query_form_field.dart';
@@ -96,14 +96,14 @@ class _DocumentFilterFormState extends State<DocumentFilterForm> {
Align(
alignment: Alignment.centerLeft,
child: Text(
S.of(context).advanced,
S.of(context)!.advanced,
style: Theme.of(context).textTheme.bodySmall,
),
),
FormBuilderExtendedDateRangePicker(
name: DocumentFilterForm.fkCreatedAt,
initialValue: widget.initialFilter.created,
labelText: S.of(context).createdAt,
labelText: S.of(context)!.createdAt,
onChanged: (_) {
_checkQueryConstraints();
},
@@ -111,7 +111,7 @@ class _DocumentFilterFormState extends State<DocumentFilterForm> {
FormBuilderExtendedDateRangePicker(
name: DocumentFilterForm.fkAddedAt,
initialValue: widget.initialFilter.added,
labelText: S.of(context).addedAt,
labelText: S.of(context)!.addedAt,
onChanged: (_) {
_checkQueryConstraints();
},
@@ -151,7 +151,7 @@ class _DocumentFilterFormState extends State<DocumentFilterForm> {
formBuilderState: widget.formKey.currentState,
name: DocumentFilterForm.fkDocumentType,
labelOptions: state.labels,
textFieldLabel: S.of(context).documentType,
textFieldLabel: S.of(context)!.documentType,
initialValue: widget.initialFilter.documentType,
prefixIcon: const Icon(Icons.description_outlined),
);
@@ -166,7 +166,7 @@ class _DocumentFilterFormState extends State<DocumentFilterForm> {
formBuilderState: widget.formKey.currentState,
name: DocumentFilterForm.fkCorrespondent,
labelOptions: state.labels,
textFieldLabel: S.of(context).correspondent,
textFieldLabel: S.of(context)!.correspondent,
initialValue: widget.initialFilter.correspondent,
prefixIcon: const Icon(Icons.person_outline),
);
@@ -181,7 +181,7 @@ class _DocumentFilterFormState extends State<DocumentFilterForm> {
formBuilderState: widget.formKey.currentState,
name: DocumentFilterForm.fkStoragePath,
labelOptions: state.labels,
textFieldLabel: S.of(context).storagePath,
textFieldLabel: S.of(context)!.storagePath,
initialValue: widget.initialFilter.storagePath,
prefixIcon: const Icon(Icons.folder_outlined),
);

View File

@@ -5,7 +5,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/documents/view/pages/documents_page.dart';
import 'package:paperless_mobile/features/documents/view/widgets/search/document_filter_form.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
enum DateRangeSelection { before, after }
@@ -74,7 +74,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
visible: MediaQuery.of(context).viewInsets.bottom == 0,
child: FloatingActionButton.extended(
icon: const Icon(Icons.done),
label: Text(S.of(context).apply),
label: Text(S.of(context)!.apply),
onPressed: _onApplyFilter,
),
),
@@ -85,7 +85,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
TextButton.icon(
onPressed: _resetFilter,
icon: const Icon(Icons.refresh),
label: Text(S.of(context).reset),
label: Text(S.of(context)!.reset),
),
],
),
@@ -133,7 +133,7 @@ class _DocumentFilterPanelState extends State<DocumentFilterPanel> {
),
Padding(
padding: EdgeInsets.only(left: _heightAnimationValue * 48),
child: Text(S.of(context).filterDocuments),
child: Text(S.of(context)!.filterDocuments),
),
],
),

View File

@@ -5,7 +5,7 @@ import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/translation/sort_field_localization_mapper.dart';
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
import 'package:paperless_mobile/features/labels/cubit/label_cubit.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class SortFieldSelectionBottomSheet extends StatefulWidget {
final SortOrder initialSortOrder;
@@ -48,12 +48,12 @@ class _SortFieldSelectionBottomSheetState
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
S.of(context).orderBy,
S.of(context)!.orderBy,
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.start,
),
TextButton(
child: Text(S.of(context).apply),
child: Text(S.of(context)!.apply),
onPressed: () {
widget.onSubmit(
_currentSortField,
@@ -105,12 +105,12 @@ class _SortFieldSelectionBottomSheetState
ButtonSegment(
icon: const FaIcon(FontAwesomeIcons.arrowDownAZ),
value: SortOrder.descending,
label: Text(S.of(context).descending),
label: Text(S.of(context)!.descending),
),
ButtonSegment(
icon: const FaIcon(FontAwesomeIcons.arrowUpZA),
value: SortOrder.ascending,
label: Text(S.of(context).ascending),
label: Text(S.of(context)!.ascending),
),
],
emptySelectionAllowed: false,

View File

@@ -3,7 +3,8 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/widgets/form_builder_fields/form_builder_type_ahead.dart';
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
import 'package:provider/provider.dart';
class TextQueryFormField extends StatelessWidget {
@@ -63,19 +64,19 @@ class TextQueryFormField extends StatelessWidget {
itemBuilder: (context) => [
PopupMenuItem(
child: ListTile(
title: Text(S.of(context).titleAndContent),
title: Text(S.of(context)!.titleAndContent),
),
value: QueryType.titleAndContent,
),
PopupMenuItem(
child: ListTile(
title: Text(S.of(context).title),
title: Text(S.of(context)!.title),
),
value: QueryType.title,
),
PopupMenuItem(
child: ListTile(
title: Text(S.of(context).extended),
title: Text(S.of(context)!.extended),
),
value: QueryType.extended,
),
@@ -89,11 +90,11 @@ class TextQueryFormField extends StatelessWidget {
String _buildLabelText(BuildContext context, QueryType queryType) {
switch (queryType) {
case QueryType.title:
return S.of(context).title;
return S.of(context)!.title;
case QueryType.titleAndContent:
return S.of(context).titleAndContent;
return S.of(context)!.titleAndContent;
case QueryType.extended:
return S.of(context).extended;
return S.of(context)!.extended;
default:
return '';
}

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class BulkDeleteConfirmationDialog extends StatelessWidget {
final DocumentsState state;
@@ -14,24 +14,24 @@ class BulkDeleteConfirmationDialog extends StatelessWidget {
Widget build(BuildContext context) {
assert(state.selection.isNotEmpty);
return AlertDialog(
title: Text(S.of(context).confirmDeletion),
title: Text(S.of(context)!.confirmDeletion),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
S.of(context).areYouSureYouWantToDeleteTheFollowingDocuments(
S.of(context)!.areYouSureYouWantToDeleteTheFollowingDocuments(
state.selection.length),
),
const SizedBox(height: 16),
...state.selection.map(_buildBulletPoint).toList(),
const SizedBox(height: 16),
Text(S.of(context).thisActionIsIrreversibleDoYouWishToProceedAnyway),
Text(S.of(context)!.thisActionIsIrreversibleDoYouWishToProceedAnyway),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: Text(S.of(context).cancel),
child: Text(S.of(context)!.cancel),
),
TextButton(
style: ButtonStyle(
@@ -41,7 +41,7 @@ class BulkDeleteConfirmationDialog extends StatelessWidget {
onPressed: () {
Navigator.pop(context, true);
},
child: Text(S.of(context).delete),
child: Text(S.of(context)!.delete),
),
],
);

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class ConfirmDeleteSavedViewDialog extends StatelessWidget {
const ConfirmDeleteSavedViewDialog({
@@ -14,18 +14,18 @@ class ConfirmDeleteSavedViewDialog extends StatelessWidget {
Widget build(BuildContext context) {
return AlertDialog(
title: Text(
S.of(context).deleteView + view.name + "?",
S.of(context)!.deleteView + view.name + "?",
softWrap: true,
),
content: Text(S.of(context).doYouReallyWantToDeleteThisView),
content: Text(S.of(context)!.doYouReallyWantToDeleteThisView),
actions: [
TextButton(
child: Text(S.of(context).cancel),
child: Text(S.of(context)!.cancel),
onPressed: () => Navigator.pop(context, false),
),
TextButton(
child: Text(
S.of(context).delete,
S.of(context)!.delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onPressed: () => Navigator.pop(context, true),

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:paperless_mobile/features/settings/model/view_type.dart';
import 'package:paperless_mobile/generated/l10n.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
/// Meant to be used with blocbuilder.
class ViewTypeSelectionWidget extends StatelessWidget {
@@ -34,19 +34,19 @@ class ViewTypeSelectionWidget extends StatelessWidget {
_buildViewTypeOption(
context,
type: ViewType.list,
label: S.of(context).list,
label: S.of(context)!.list,
icon: Icons.list,
),
_buildViewTypeOption(
context,
type: ViewType.grid,
label: S.of(context).grid,
label: S.of(context)!.grid,
icon: Icons.grid_view_rounded,
),
_buildViewTypeOption(
context,
type: ViewType.detailed,
label: S.of(context).detailed,
label: S.of(context)!.detailed,
icon: Icons.article_outlined,
),
],