mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 04:08:03 -06:00
feat: Migrated strings, and translations to native flutter l10n plugin
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
// import 'package:paperless_mobile/features/settings/bloc/application_settings_state.dart';
|
||||
// import 'package:paperless_mobile/features/settings/model/view_type.dart';
|
||||
// import 'package:paperless_mobile/features/settings/view/settings_page.dart';
|
||||
// import 'package:paperless_mobile/generated/l10n.dart';
|
||||
// import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
// import 'package:url_launcher/link.dart';
|
||||
// import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
@@ -74,7 +75,7 @@
|
||||
// padding: EdgeInsets.zero,
|
||||
// child: ListTile(
|
||||
// leading: const Icon(Icons.bug_report),
|
||||
// title: Text(S.of(context).reportABug),
|
||||
// title: Text(S.of(context)!.reportABug),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
@@ -85,7 +86,7 @@
|
||||
// value: AppPopupMenuEntries.openSettings,
|
||||
// child: ListTile(
|
||||
// leading: const Icon(Icons.settings_outlined),
|
||||
// title: Text(S.of(context).settings),
|
||||
// title: Text(S.of(context)!.settings),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
@@ -96,7 +97,7 @@
|
||||
// value: AppPopupMenuEntries.openAboutThisAppDialog,
|
||||
// child: ListTile(
|
||||
// leading: const Icon(Icons.info_outline),
|
||||
// title: Text(S.of(context).aboutThisApp),
|
||||
// title: Text(S.of(context)!.aboutThisApp),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
@@ -146,7 +147,7 @@
|
||||
// applicationName: 'Paperless Mobile',
|
||||
// applicationVersion: packageInfo.version + '+' + packageInfo.buildNumber,
|
||||
// children: [
|
||||
// Text(S.of(context).developedBy('Anton Stubenbord')),
|
||||
// Text(S.of(context)!.developedBy('Anton Stubenbord')),
|
||||
// Link(
|
||||
// uri: Uri.parse('https://github.com/astubenbord/paperless-mobile'),
|
||||
// builder: (context, followLink) => GestureDetector(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter/src/widgets/placeholder.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class DialogCancelButton extends StatelessWidget {
|
||||
final void Function()? onTap;
|
||||
@@ -10,7 +10,7 @@ class DialogCancelButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton(
|
||||
child: Text(S.of(context).cancel),
|
||||
child: Text(S.of(context)!.cancel),
|
||||
onPressed: onTap ?? () => Navigator.pop(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/widgets/form_builder_fields/extended_date_range_form_field/form_builder_relative_date_range_field.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class ExtendedDateRangeDialog extends StatefulWidget {
|
||||
final DateRangeQuery initialValue;
|
||||
@@ -47,7 +47,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
insetPadding: const EdgeInsets.all(24.0),
|
||||
title: Text(S.of(context).selectDateRange),
|
||||
title: Text(S.of(context)!.selectDateRange),
|
||||
content: FormBuilder(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
@@ -56,7 +56,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
children: [
|
||||
_buildDateRangeQueryTypeSelection(),
|
||||
Text(
|
||||
S.of(context).hintYouCanAlsoSpecifyRelativeValues,
|
||||
S.of(context)!.hintYouCanAlsoSpecifyRelativeValues,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
).paddedOnly(top: 8, bottom: 16),
|
||||
Builder(
|
||||
@@ -83,11 +83,11 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(S.of(context).cancel),
|
||||
child: Text(S.of(context)!.cancel),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(S.of(context).save),
|
||||
child: Text(S.of(context)!.save),
|
||||
onPressed: () {
|
||||
_formKey.currentState?.save();
|
||||
if (_formKey.currentState?.validate() ?? false) {
|
||||
@@ -110,12 +110,12 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
ButtonSegment(
|
||||
value: DateRangeType.absolute,
|
||||
enabled: true,
|
||||
label: Text(S.of(context).absolute),
|
||||
label: Text(S.of(context)!.absolute),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: DateRangeType.relative,
|
||||
enabled: true,
|
||||
label: Text(S.of(context).relative),
|
||||
label: Text(S.of(context)!.relative),
|
||||
),
|
||||
],
|
||||
selected: {_selectedDateRangeType},
|
||||
@@ -133,7 +133,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
: null,
|
||||
initialDate: _before?.subtract(const Duration(days: 1)),
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).after,
|
||||
labelText: S.of(context)!.after,
|
||||
prefixIcon: const Icon(Icons.date_range),
|
||||
suffixIcon: _after != null
|
||||
? IconButton(
|
||||
@@ -161,7 +161,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
||||
: null,
|
||||
inputType: InputType.date,
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).before,
|
||||
labelText: S.of(context)!.before,
|
||||
prefixIcon: const Icon(Icons.date_range),
|
||||
suffixIcon: _before != null
|
||||
? IconButton(
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/widgets/form_builder_fields/extended_date_range_form_field/extended_date_range_dialog.dart';
|
||||
import 'package:paperless_mobile/core/widgets/form_builder_fields/extended_date_range_form_field/relative_date_range_picker_helper.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class FormBuilderExtendedDateRangePicker extends StatefulWidget {
|
||||
final String name;
|
||||
@@ -90,21 +90,21 @@ class _FormBuilderExtendedDateRangePickerState
|
||||
return '${df.format(query.after!)} – ${df.format(query.before!)}';
|
||||
}
|
||||
if (query.before != null) {
|
||||
return '${S.of(context).before} ${df.format(query.before!)}';
|
||||
return '${S.of(context)!.before} ${df.format(query.before!)}';
|
||||
}
|
||||
if (query.after != null) {
|
||||
return '${S.of(context).after} ${df.format(query.after!)}';
|
||||
return '${S.of(context)!.after} ${df.format(query.after!)}';
|
||||
}
|
||||
} else if (query is RelativeDateRangeQuery) {
|
||||
switch (query.unit) {
|
||||
case DateRangeUnit.day:
|
||||
return S.of(context).lastNDays(query.offset);
|
||||
return S.of(context)!.lastNDays(query.offset);
|
||||
case DateRangeUnit.week:
|
||||
return S.of(context).lastNWeeks(query.offset);
|
||||
return S.of(context)!.lastNWeeks(query.offset);
|
||||
case DateRangeUnit.month:
|
||||
return S.of(context).lastNMonths(query.offset);
|
||||
return S.of(context)!.lastNMonths(query.offset);
|
||||
case DateRangeUnit.year:
|
||||
return S.of(context).lastNYears(query.offset);
|
||||
return S.of(context)!.lastNYears(query.offset);
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.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 FormBuilderRelativeDateRangePicker extends StatefulWidget {
|
||||
final String name;
|
||||
@@ -46,12 +46,12 @@ class _FormBuilderRelativeDateRangePickerState
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(S.of(context).last),
|
||||
Text(S.of(context)!.last),
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).amount,
|
||||
labelText: S.of(context)!.amount,
|
||||
),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
@@ -90,7 +90,7 @@ class _FormBuilderRelativeDateRangePickerState
|
||||
onChanged: (value) =>
|
||||
field.didChange(field.value!.copyWith(unit: value)),
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).timeUnit,
|
||||
labelText: S.of(context)!.timeUnit,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -113,13 +113,13 @@ class _FormBuilderRelativeDateRangePickerState
|
||||
String _dateRangeUnitToLocalizedString(DateRangeUnit unit, int? count) {
|
||||
switch (unit) {
|
||||
case DateRangeUnit.day:
|
||||
return S.of(context).days(count ?? 1);
|
||||
return S.of(context)!.days(count ?? 1);
|
||||
case DateRangeUnit.week:
|
||||
return S.of(context).weeks(count ?? 1);
|
||||
return S.of(context)!.weeks(count ?? 1);
|
||||
case DateRangeUnit.month:
|
||||
return S.of(context).months(count ?? 1);
|
||||
return S.of(context)!.months(count ?? 1);
|
||||
case DateRangeUnit.year:
|
||||
return S.of(context).years(count ?? 1);
|
||||
return S.of(context)!.years(count ?? 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class RelativeDateRangePickerHelper extends StatefulWidget {
|
||||
final FormFieldState<DateRangeQuery> field;
|
||||
@@ -49,19 +49,19 @@ class _RelativeDateRangePickerHelperState
|
||||
|
||||
List<_ExtendedDateRangeQueryOption> get _options => [
|
||||
_ExtendedDateRangeQueryOption(
|
||||
S.of(context).lastNWeeks(1),
|
||||
S.of(context)!.lastNWeeks(1),
|
||||
const RelativeDateRangeQuery(1, DateRangeUnit.week),
|
||||
),
|
||||
_ExtendedDateRangeQueryOption(
|
||||
S.of(context).lastNMonths(1),
|
||||
S.of(context)!.lastNMonths(1),
|
||||
const RelativeDateRangeQuery(1, DateRangeUnit.month),
|
||||
),
|
||||
_ExtendedDateRangeQueryOption(
|
||||
S.of(context).lastNMonths(3),
|
||||
S.of(context)!.lastNMonths(3),
|
||||
const RelativeDateRangeQuery(3, DateRangeUnit.month),
|
||||
),
|
||||
_ExtendedDateRangeQueryOption(
|
||||
S.of(context).lastNYears(1),
|
||||
S.of(context)!.lastNYears(1),
|
||||
const RelativeDateRangeQuery(1, DateRangeUnit.year),
|
||||
),
|
||||
];
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
extension on Color {
|
||||
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
|
||||
@@ -213,7 +214,7 @@ class FormBuilderColorPickerFieldState
|
||||
final selected = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
final materialLocalizations = MaterialLocalizations.of(context);
|
||||
final materialLocalizations = S.of(context)!;
|
||||
|
||||
return AlertDialog(
|
||||
// title: null, //const Text('Pick a color!'),
|
||||
@@ -223,11 +224,11 @@ class FormBuilderColorPickerFieldState
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: Text(materialLocalizations.cancelButtonLabel),
|
||||
child: Text(materialLocalizations.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(materialLocalizations.okButtonLabel),
|
||||
child: Text(materialLocalizations.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class HintCard extends StatelessWidget {
|
||||
final String hintText;
|
||||
@@ -52,7 +52,7 @@ class HintCard extends StatelessWidget {
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: TextButton(
|
||||
child: Text(S.of(context).gotIt),
|
||||
child: Text(S.of(context)!.gotIt),
|
||||
onPressed: onHintAcknowledged,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
/// Shows a full screen search page and returns the search result selected by
|
||||
/// the user when the page is closed.
|
||||
@@ -308,7 +309,7 @@ abstract class SearchDelegate<T> {
|
||||
/// The hint text that is shown in the search field when it is empty.
|
||||
///
|
||||
/// If this value is set to null, the value of
|
||||
/// `MaterialLocalizations.of(context).searchFieldLabel` will be used instead.
|
||||
/// `MaterialLocalizationS.of(context)!.searchFieldLabel` will be used instead.
|
||||
final String? searchFieldLabel;
|
||||
|
||||
/// The style of the [searchFieldLabel].
|
||||
@@ -532,8 +533,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
|
||||
Widget build(BuildContext context) {
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
final ThemeData theme = widget.delegate.appBarTheme(context);
|
||||
final String searchFieldLabel = widget.delegate.searchFieldLabel ??
|
||||
MaterialLocalizations.of(context).searchFieldLabel;
|
||||
final String searchFieldLabel =
|
||||
widget.delegate.searchFieldLabel ?? S.of(context)!.search;
|
||||
Widget? body;
|
||||
switch (widget.delegate._currentBody) {
|
||||
case _SearchBody.suggestions:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class OfflineBanner extends StatelessWidget with PreferredSizeWidget {
|
||||
const OfflineBanner({super.key});
|
||||
@@ -21,7 +21,7 @@ class OfflineBanner extends StatelessWidget with PreferredSizeWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
S.of(context).youreOffline,
|
||||
S.of(context)!.youreOffline,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onErrorContainer,
|
||||
),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class OfflineWidget extends StatelessWidget {
|
||||
const OfflineWidget({super.key});
|
||||
@@ -15,7 +15,7 @@ class OfflineWidget extends StatelessWidget {
|
||||
color: Theme.of(context).disabledColor,
|
||||
size: (Theme.of(context).iconTheme.size ?? 24) * 3),
|
||||
Text(
|
||||
S.of(context).anInternetConnectionCouldNotBeEstablished,
|
||||
S.of(context)!.anInternetConnectionCouldNotBeEstablished,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user