mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 18:07:59 -06:00
feat: Migrated strings, and translations to native flutter l10n plugin
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/features/settings/cubit/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class BiometricAuthenticationSetting extends StatelessWidget {
|
||||
const BiometricAuthenticationSetting({super.key});
|
||||
@@ -12,11 +12,11 @@ class BiometricAuthenticationSetting extends StatelessWidget {
|
||||
builder: (context, settings) {
|
||||
return SwitchListTile(
|
||||
value: settings.isLocalAuthenticationEnabled,
|
||||
title: Text(S.of(context).biometricAuthentication),
|
||||
subtitle: Text(S.of(context).authenticateOnAppStart),
|
||||
title: Text(S.of(context)!.biometricAuthentication),
|
||||
subtitle: Text(S.of(context)!.authenticateOnAppStart),
|
||||
onChanged: (val) async {
|
||||
final String localizedReason =
|
||||
S.of(context).authenticateToToggleBiometricAuthentication(
|
||||
S.of(context)!.authenticateToToggleBiometricAuthentication(
|
||||
val ? 'enable' : 'disable',
|
||||
);
|
||||
await context
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:paperless_mobile/core/widgets/hint_card.dart';
|
||||
import 'package:paperless_mobile/features/settings/cubit/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/model/color_scheme_option.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/radio_settings_dialog.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class ColorSchemeOptionSetting extends StatelessWidget {
|
||||
const ColorSchemeOptionSetting({super.key});
|
||||
@@ -18,7 +18,7 @@ class ColorSchemeOptionSetting extends StatelessWidget {
|
||||
return BlocBuilder<ApplicationSettingsCubit, ApplicationSettingsState>(
|
||||
builder: (context, settings) {
|
||||
return ListTile(
|
||||
title: Text(S.of(context).colors),
|
||||
title: Text(S.of(context)!.colors),
|
||||
subtitle: Text(
|
||||
translateColorSchemeOption(
|
||||
context,
|
||||
@@ -28,8 +28,8 @@ class ColorSchemeOptionSetting extends StatelessWidget {
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (_) => RadioSettingsDialog<ColorSchemeOption>(
|
||||
titleText: S.of(context).colors,
|
||||
descriptionText: S.of(context).colorSchemeHint,
|
||||
titleText: S.of(context)!.colors,
|
||||
descriptionText: S.of(context)!.colorSchemeHint,
|
||||
options: [
|
||||
RadioOption(
|
||||
value: ColorSchemeOption.classic,
|
||||
@@ -46,7 +46,7 @@ class ColorSchemeOptionSetting extends StatelessWidget {
|
||||
],
|
||||
footer: _isBelowAndroid12()
|
||||
? HintCard(
|
||||
hintText: S.of(context).colorSchemeNotSupportedWarning,
|
||||
hintText: S.of(context)!.colorSchemeNotSupportedWarning,
|
||||
hintIcon: Icons.warning_amber,
|
||||
)
|
||||
: null,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/features/settings/cubit/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/radio_settings_dialog.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class LanguageSelectionSetting extends StatefulWidget {
|
||||
const LanguageSelectionSetting({super.key});
|
||||
@@ -25,7 +25,7 @@ class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||
return BlocBuilder<ApplicationSettingsCubit, ApplicationSettingsState>(
|
||||
builder: (context, settings) {
|
||||
return ListTile(
|
||||
title: Text(S.of(context).language),
|
||||
title: Text(S.of(context)!.language),
|
||||
subtitle: Text(_languageOptions[settings.preferredLocaleSubtag]!),
|
||||
onTap: () => showDialog<String>(
|
||||
context: context,
|
||||
@@ -33,7 +33,7 @@ class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||
footer: const Text(
|
||||
"* Work in progress, not fully translated yet. Some words may be displayed in English!",
|
||||
),
|
||||
titleText: S.of(context).language,
|
||||
titleText: S.of(context)!.language,
|
||||
options: [
|
||||
RadioOption(
|
||||
value: 'en',
|
||||
|
||||
@@ -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 RadioSettingsDialog<T> extends StatefulWidget {
|
||||
final List<RadioOption<T>> options;
|
||||
@@ -41,11 +41,11 @@ class _RadioSettingsDialogState<T> extends State<RadioSettingsDialog<T>> {
|
||||
widget.confirmButton ??
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(S.of(context).cancel)),
|
||||
child: Text(S.of(context)!.cancel)),
|
||||
widget.confirmButton ??
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, _groupValue),
|
||||
child: Text(S.of(context).ok)),
|
||||
child: Text(S.of(context)!.ok)),
|
||||
],
|
||||
title: widget.titleText != null ? Text(widget.titleText!) : null,
|
||||
content: Column(
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/features/settings/cubit/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/radio_settings_dialog.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class ThemeModeSetting extends StatelessWidget {
|
||||
const ThemeModeSetting({super.key});
|
||||
@@ -12,13 +12,13 @@ class ThemeModeSetting extends StatelessWidget {
|
||||
return BlocBuilder<ApplicationSettingsCubit, ApplicationSettingsState>(
|
||||
builder: (context, settings) {
|
||||
return ListTile(
|
||||
title: Text(S.of(context).appearance),
|
||||
title: Text(S.of(context)!.appearance),
|
||||
subtitle: Text(_mapThemeModeToLocalizedString(
|
||||
settings.preferredThemeMode, context)),
|
||||
onTap: () => showDialog<ThemeMode>(
|
||||
context: context,
|
||||
builder: (_) => RadioSettingsDialog<ThemeMode>(
|
||||
titleText: S.of(context).appearance,
|
||||
titleText: S.of(context)!.appearance,
|
||||
initialValue: context
|
||||
.read<ApplicationSettingsCubit>()
|
||||
.state
|
||||
@@ -26,15 +26,15 @@ class ThemeModeSetting extends StatelessWidget {
|
||||
options: [
|
||||
RadioOption(
|
||||
value: ThemeMode.system,
|
||||
label: S.of(context).systemTheme,
|
||||
label: S.of(context)!.systemTheme,
|
||||
),
|
||||
RadioOption(
|
||||
value: ThemeMode.light,
|
||||
label: S.of(context).lightTheme,
|
||||
label: S.of(context)!.lightTheme,
|
||||
),
|
||||
RadioOption(
|
||||
value: ThemeMode.dark,
|
||||
label: S.of(context).darkTheme,
|
||||
label: S.of(context)!.darkTheme,
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -51,11 +51,11 @@ class ThemeModeSetting extends StatelessWidget {
|
||||
String _mapThemeModeToLocalizedString(ThemeMode theme, BuildContext context) {
|
||||
switch (theme) {
|
||||
case ThemeMode.system:
|
||||
return S.of(context).system;
|
||||
return S.of(context)!.system;
|
||||
case ThemeMode.light:
|
||||
return S.of(context).light;
|
||||
return S.of(context)!.light;
|
||||
case ThemeMode.dark:
|
||||
return S.of(context).dark;
|
||||
return S.of(context)!.dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user