Skip to content

Commit

Permalink
feat: extract defineLocale function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Jul 10, 2024
1 parent 99d613b commit ff55e8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/loaders/file_translation_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FileTranslationLoader extends TranslationLoader implements IFileContent {
/// Return the translation Map
Future<Map> load() async {
_decodedMap = Map();
await this._defineLocale();
await _loadCurrentTranslation();
await _loadFallback();
return _decodedMap;
Expand All @@ -62,14 +63,17 @@ class FileTranslationLoader extends TranslationLoader implements IFileContent {

Future _loadCurrentTranslation() async {
try {
this.locale = locale ?? await findDeviceLocale();
MessagePrinter.info("The current locale is ${this.locale}");
_decodedMap.addAll(await loadFile(composeFileName()));
} catch (e) {
MessagePrinter.debug('Error loading translation $e');
}
}

Future _defineLocale() async {
this.locale = locale ?? await findDeviceLocale();
MessagePrinter.info("The current locale is ${this.locale}");
}

Future _loadFallback() async {
try {
final Map fallbackMap = await loadFile(fallbackFile);
Expand Down

0 comments on commit ff55e8b

Please sign in to comment.