mirror of
https://github.com/immich-app/immich.git
synced 2024-11-15 18:08:48 -07:00
c1253663b7
* refactor(mobile): services and provider * providers
32 lines
1.1 KiB
Dart
32 lines
1.1 KiB
Dart
// ignore_for_file: implementation_imports
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:easy_localization/src/asset_loader.dart';
|
|
import 'package:easy_localization/src/easy_localization_controller.dart';
|
|
import 'package:easy_localization/src/localization.dart';
|
|
import 'package:immich_mobile/constants/locales.dart';
|
|
|
|
/// Workaround to manually load translations in another Isolate
|
|
Future<bool> loadTranslations() async {
|
|
await EasyLocalizationController.initEasyLocation();
|
|
|
|
final controller = EasyLocalizationController(
|
|
supportedLocales: locales.values.toList(),
|
|
useFallbackTranslations: true,
|
|
saveLocale: true,
|
|
assetLoader: const RootBundleAssetLoader(),
|
|
path: translationsPath,
|
|
useOnlyLangCode: false,
|
|
onLoadError: (e) => debugPrint(e.toString()),
|
|
fallbackLocale: locales.values.first,
|
|
);
|
|
|
|
await controller.loadTranslations();
|
|
|
|
return Localization.load(
|
|
controller.locale,
|
|
translations: controller.translations,
|
|
fallbackTranslations: controller.fallbackTranslations,
|
|
);
|
|
}
|