diff --git a/pkgs/messages_builder/lib/code_generation/import_generation.dart b/pkgs/messages_builder/lib/code_generation/import_generation.dart index 1ab73f87..d927f6dc 100644 --- a/pkgs/messages_builder/lib/code_generation/import_generation.dart +++ b/pkgs/messages_builder/lib/code_generation/import_generation.dart @@ -8,8 +8,10 @@ import '../generation_options.dart'; class ImportGeneration { final GenerationOptions options; + final List locales; + final String name; - ImportGeneration(this.options); + ImportGeneration(this.options, this.locales, this.name); List generate() { final serializationImports = switch (options.deserialization) { @@ -24,9 +26,13 @@ class ImportGeneration { ], PluralSelectorType.custom => [], }; + + final deferredImports = locales.map((e) => Directive.importDeferredAs( + '${name}_${e}_empty.dart', '${name}_${e}_empty')); return [ ...serializationImports, ...pluralImports, + ...deferredImports, ]; } } diff --git a/pkgs/messages_builder/lib/code_generation/method_generation.dart b/pkgs/messages_builder/lib/code_generation/method_generation.dart index c21abe90..e00b1f00 100644 --- a/pkgs/messages_builder/lib/code_generation/method_generation.dart +++ b/pkgs/messages_builder/lib/code_generation/method_generation.dart @@ -79,6 +79,11 @@ class MethodGeneration { if (dataFile == null) { throw ArgumentError('Locale \$locale is not in \$knownLocales'); } + if (locale.startsWith('en')) { + await empty_en.loadLibrary(); + } else if (locale.startsWith('de')) { + await empty_de.loadLibrary(); + } $loading if (messageList.preamble.hash != info?.\$2) { throw ArgumentError(\'\'\'