mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 20:57:36 +02:00
feat: Allow changing languages (#1488)
Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
@ -4,11 +4,11 @@ import 'package:device_apps/device_apps.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/models/patch.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/github_api.dart';
|
||||
@ -58,8 +58,7 @@ class ManagerAPI {
|
||||
}
|
||||
|
||||
bool isDefaultIntegrationsRepo() {
|
||||
return getIntegrationsRepo().toLowerCase() ==
|
||||
defaultIntegrationsRepo;
|
||||
return getIntegrationsRepo().toLowerCase() == defaultIntegrationsRepo;
|
||||
}
|
||||
|
||||
Future<void> initialize() async {
|
||||
@ -99,7 +98,7 @@ class ManagerAPI {
|
||||
}
|
||||
await _revancedAPI.clearAllCache();
|
||||
await _prefs.setString('apiUrl', url);
|
||||
_toast.showBottom('settingsView.restartAppForChanges');
|
||||
_toast.showBottom(t.settingsView.restartAppForChanges);
|
||||
}
|
||||
|
||||
String getRepoUrl() {
|
||||
@ -302,6 +301,14 @@ class ManagerAPI {
|
||||
return _prefs.getString('keystorePassword') ?? defaultKeystorePassword;
|
||||
}
|
||||
|
||||
String getLocale() {
|
||||
return _prefs.getString('locale') ?? 'en';
|
||||
}
|
||||
|
||||
Future<void> setLocale(String value) async {
|
||||
await _prefs.setString('locale', value);
|
||||
}
|
||||
|
||||
Future<void> deleteTempFolder() async {
|
||||
final Directory dir = Directory('/data/local/tmp/revanced-manager');
|
||||
if (await dir.exists()) {
|
||||
@ -615,7 +622,7 @@ class ManagerAPI {
|
||||
builder: (context) => PopScope(
|
||||
canPop: false,
|
||||
child: AlertDialog(
|
||||
title: I18nText('warning'),
|
||||
title: Text(t.warning),
|
||||
content: ValueListenableBuilder(
|
||||
valueListenable: noShow,
|
||||
builder: (context, value, child) {
|
||||
@ -623,22 +630,19 @@ class ManagerAPI {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
I18nText(
|
||||
'patchItem.patchesChangeWarningDialogText',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
Text(
|
||||
t.patchItem.patchesChangeWarningDialogText,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
HapticCheckboxListTile(
|
||||
value: value,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: I18nText(
|
||||
'noShowAgain',
|
||||
title: Text(
|
||||
t.noShowAgain,
|
||||
),
|
||||
onChanged: (selected) {
|
||||
noShow.value = selected!;
|
||||
@ -654,7 +658,7 @@ class ManagerAPI {
|
||||
setPatchesChangeWarning(noShow.value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -6,10 +6,10 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/gen/strings.g.dart';
|
||||
import 'package:revanced_manager/models/patch.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
@ -304,18 +304,19 @@ class PatcherAPI {
|
||||
context: _managerAPI.ctx!,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
title: I18nText('installErrorDialog.$statusValue'),
|
||||
title: Text(t['installErrorDialog.$statusValue']),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
I18nText(
|
||||
'installErrorDialog.${statusValue}_description',
|
||||
translationParams: statusCode == 2
|
||||
? {
|
||||
'packageName': status['otherPackageName'],
|
||||
}
|
||||
: null,
|
||||
Text(
|
||||
t['installErrorDialog.${statusValue}_description'](
|
||||
packageName: statusCode == 2
|
||||
? {
|
||||
'packageName': status['otherPackageName'],
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -325,7 +326,7 @@ class PatcherAPI {
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
]
|
||||
: <Widget>[
|
||||
@ -334,14 +335,14 @@ class PatcherAPI {
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
)
|
||||
else
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: I18nText('cancelButton'),
|
||||
child: Text(t.cancelButton),
|
||||
),
|
||||
if (isFixable)
|
||||
FilledButton(
|
||||
@ -355,7 +356,7 @@ class PatcherAPI {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: I18nText('okButton'),
|
||||
child: Text(t.okButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart' as t;
|
||||
|
||||
class Toast {
|
||||
@ -12,10 +11,7 @@ class Toast {
|
||||
|
||||
void show(String text) {
|
||||
t.Fluttertoast.showToast(
|
||||
msg: FlutterI18n.translate(
|
||||
_fToast.context!,
|
||||
text,
|
||||
),
|
||||
msg: text,
|
||||
toastLength: t.Toast.LENGTH_LONG,
|
||||
gravity: t.ToastGravity.CENTER,
|
||||
);
|
||||
@ -23,10 +19,7 @@ class Toast {
|
||||
|
||||
void showBottom(String text) {
|
||||
t.Fluttertoast.showToast(
|
||||
msg: FlutterI18n.translate(
|
||||
_fToast.context!,
|
||||
text,
|
||||
),
|
||||
msg: text,
|
||||
toastLength: t.Toast.LENGTH_LONG,
|
||||
gravity: t.ToastGravity.BOTTOM,
|
||||
);
|
||||
|
Reference in New Issue
Block a user