feat: Allow changing languages (#1488)

Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
Ushie 2024-02-12 02:22:25 +03:00 committed by GitHub
parent c498cff096
commit f82c439b26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 1302 additions and 1488 deletions

View file

@ -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),
),
],
),