Merge pull request #529 from ImranR98/dev

SourceForge URL flexibility (#525), Add language names, enable Spanish
This commit is contained in:
Imran Remtulla
2023-05-03 18:02:05 -04:00
committed by GitHub
6 changed files with 39 additions and 32 deletions

View File

@@ -10,8 +10,14 @@ class SourceForge extends AppSource {
@override @override
String sourceSpecificStandardizeURL(String url) { String sourceSpecificStandardizeURL(String url) {
RegExp standardUrlRegEx = RegExp('^https?://$host/projects/[^/]+'); RegExp standardUrlRegExB = RegExp('^https?://$host/p/[^/]+');
RegExpMatch? match = standardUrlRegEx.firstMatch(url.toLowerCase()); RegExpMatch? match = standardUrlRegExB.firstMatch(url.toLowerCase());
if (match != null) {
url =
'https://${Uri.parse(url.substring(0, match.end)).host}/projects/${url.substring(Uri.parse(url.substring(0, match.end)).host.length + '/projects/'.length + 1)}';
}
RegExp standardUrlRegExA = RegExp('^https?://$host/projects/[^/]+');
match = standardUrlRegExA.firstMatch(url.toLowerCase());
if (match == null) { if (match == null) {
throw InvalidURLError(name); throw InvalidURLError(name);
} }

View File

@@ -21,21 +21,22 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
// ignore: implementation_imports // ignore: implementation_imports
import 'package:easy_localization/src/localization.dart'; import 'package:easy_localization/src/localization.dart';
const String currentVersion = '0.12.2'; const String currentVersion = '0.12.3';
const String currentReleaseTag = const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
const int bgUpdateCheckAlarmId = 666; const int bgUpdateCheckAlarmId = 666;
const supportedLocales = [ List<MapEntry<Locale, String>> supportedLocales = const [
Locale('en'), MapEntry(Locale('en'), 'English'),
Locale('zh'), MapEntry(Locale('zh'), '汉语'),
Locale('it'), MapEntry(Locale('it'), 'Italiano'),
Locale('ja'), MapEntry(Locale('ja'), '日本語'),
Locale('hu'), MapEntry(Locale('hu'), 'Magyar'),
Locale('de'), MapEntry(Locale('de'), 'Deutsch'),
Locale('fa'), MapEntry(Locale('fa'), 'فارسی'),
Locale('fr') MapEntry(Locale('fr'), 'Français'),
MapEntry(Locale('es'), 'Español'),
]; ];
const fallbackLocale = Locale('en'); const fallbackLocale = Locale('en');
const localeDir = 'assets/translations'; const localeDir = 'assets/translations';
@@ -52,7 +53,7 @@ Future<void> loadTranslations() async {
saveLocale: true, saveLocale: true,
forceLocale: forceLocale != null ? Locale(forceLocale) : null, forceLocale: forceLocale != null ? Locale(forceLocale) : null,
fallbackLocale: fallbackLocale, fallbackLocale: fallbackLocale,
supportedLocales: supportedLocales, supportedLocales: supportedLocales.map((e) => e.key).toList(),
assetLoader: const RootBundleAssetLoader(), assetLoader: const RootBundleAssetLoader(),
useOnlyLangCode: true, useOnlyLangCode: true,
useFallbackTranslations: true, useFallbackTranslations: true,
@@ -171,7 +172,7 @@ void main() async {
Provider(create: (context) => LogsProvider()) Provider(create: (context) => LogsProvider())
], ],
child: EasyLocalization( child: EasyLocalization(
supportedLocales: supportedLocales, supportedLocales: supportedLocales.map((e) => e.key).toList(),
path: localeDir, path: localeDir,
fallbackLocale: fallbackLocale, fallbackLocale: fallbackLocale,
useOnlyLangCode: true, useOnlyLangCode: true,
@@ -221,7 +222,7 @@ class _ObtainiumState extends State<Obtainium> {
], onlyIfExists: false); ], onlyIfExists: false);
} }
if (!supportedLocales if (!supportedLocales
.map((e) => e.languageCode) .map((e) => e.key.languageCode)
.contains(context.locale.languageCode) || .contains(context.locale.languageCode) ||
settingsProvider.forcedLocale == null && settingsProvider.forcedLocale == null &&
context.deviceLocale.languageCode != context.deviceLocale.languageCode !=

View File

@@ -144,8 +144,8 @@ class _SettingsPageState extends State<SettingsPage> {
child: Text(tr('followSystem')), child: Text(tr('followSystem')),
), ),
...supportedLocales.map((e) => DropdownMenuItem( ...supportedLocales.map((e) => DropdownMenuItem(
value: e.toLanguageTag(), value: e.key.toLanguageTag(),
child: Text(e.toLanguageTag().toUpperCase()), child: Text(e.value),
)) ))
], ],
onChanged: (value) { onChanged: (value) {

View File

@@ -216,7 +216,7 @@ class SettingsProvider with ChangeNotifier {
String? get forcedLocale { String? get forcedLocale {
var fl = prefs?.getString('forcedLocale'); var fl = prefs?.getString('forcedLocale');
return supportedLocales return supportedLocales
.where((element) => element.toLanguageTag() == fl) .where((element) => element.key.toLanguageTag() == fl)
.isNotEmpty .isNotEmpty
? fl ? fl
: null; : null;
@@ -226,7 +226,7 @@ class SettingsProvider with ChangeNotifier {
if (fl == null) { if (fl == null) {
prefs?.remove('forcedLocale'); prefs?.remove('forcedLocale');
} else if (supportedLocales } else if (supportedLocales
.where((element) => element.toLanguageTag() == fl) .where((element) => element.key.toLanguageTag() == fl)
.isNotEmpty) { .isNotEmpty) {
prefs?.setString('forcedLocale', fl); prefs?.setString('forcedLocale', fl);
} }

View File

@@ -38,10 +38,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: args name: args
sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.0" version: "2.4.1"
async: async:
dependency: transitive dependency: transitive
description: description:
@@ -282,18 +282,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: html name: html
sha256: "79d498e6d6761925a34ee5ea8fa6dfef38607781d2fa91e37523474282af55cb" sha256: "58e3491f7bf0b6a4ea5110c0c688877460d1a6366731155c4a4580e7ded773e8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.15.2" version: "0.15.3"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:
name: http name: http
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.5" version: "0.13.6"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
@@ -338,10 +338,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: markdown name: markdown
sha256: d95a9d12954aafc97f984ca29baaa7690ed4d9ec4140a23ad40580bcdb6c87f5 sha256: "8e332924094383133cee218b676871f42db2514f1f6ac617b6cf6152a7faab8e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.2" version: "7.1.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@@ -791,10 +791,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_android name: webview_flutter_android
sha256: d6cf18cd6c809c5a9294cd99707a21986aac4e08c87e1916ce2590315fb55d3a sha256: "1acea8def62592123e2fbbca164ed8681a98a890bdcbb88f916d5b4a22687759"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.6.2" version: "3.7.0"
webview_flutter_platform_interface: webview_flutter_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -807,10 +807,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_wkwebview name: webview_flutter_wkwebview
sha256: c94d242d8cbe1012c06ba7ac790c46d6e6b68723b7d34f8c74ed19f68d166f49 sha256: "61f33512810bf1ee9ac89761a4b02663ff64e8227b7dc80654642acd660fd49d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.4.0" version: "3.4.2"
win32: win32:
dependency: transitive dependency: transitive
description: description:

View File

@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 0.12.2+162 # When changing this, update the tag in main() accordingly version: 0.12.3+163 # When changing this, update the tag in main() accordingly
environment: environment:
sdk: '>=2.18.2 <3.0.0' sdk: '>=2.18.2 <3.0.0'