Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1572)

Unified Diff: pkg/intl/lib/generate_localized.dart

Issue 414093003: Make deferred loading of message libraries optional (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a new file I had missed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/intl/bin/generate_from_arb.dart ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/generate_localized.dart
diff --git a/pkg/intl/lib/generate_localized.dart b/pkg/intl/lib/generate_localized.dart
index 000333168f594078f2d326f68fac9cf05d6fadce..78baaf3b030d68c7ac32136ac5df80edeaead394 100644
--- a/pkg/intl/lib/generate_localized.dart
+++ b/pkg/intl/lib/generate_localized.dart
@@ -53,6 +53,11 @@ List<String> allLocales = [];
String generatedFilePrefix = '';
/**
+ * Should we use deferred loading for the generated libraries.
+ */
+bool useDeferredLoading = true;
+
+/**
* This represents a message and its translation. We assume that the translation
* has some identifier that allows us to figure out the original message it
* corresponds to, and that it may want to transform the translated text in
@@ -179,13 +184,18 @@ String generateMainImportFile() {
for (var locale in allLocales) {
var baseFile = '${generatedFilePrefix}messages_$locale.dart';
var file = importForGeneratedFile(baseFile);
- output.write("import '$file' deferred as ${_libraryName(locale)};\n");
+ output.write("import '$file' ");
+ if (useDeferredLoading) output.write("deferred ");
+ output.write("as ${_libraryName(locale)};\n");
}
output.write("\n");
output.write("\nMap<String, Function> _deferredLibraries = {\n");
for (var rawLocale in allLocales) {
var locale = Intl.canonicalizedLocale(rawLocale);
- output.write(" '$locale' : () => ${_libraryName(locale)}.loadLibrary(),\n");
+ var loadOperation = (useDeferredLoading)
+ ? " '$locale' : () => ${_libraryName(locale)}.loadLibrary(),\n"
+ : " '$locale' : () => new Future.value(null),\n";
+ output.write(loadOperation);
}
output.write("};\n");
output.write(
« no previous file with comments | « pkg/intl/bin/generate_from_arb.dart ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698