Remove the library directive from generated message files. Support @@locale directive in ARB files.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=111855991
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 461b8c7..9334025 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
 ## 0.12.6
   * Update links in README.md to point to current dartdocs.
   * Update locale data to CLDR 28.
+  * Remove library directive from generated libraries. Conflicted with linter.
+  * Support @@locale in ARB files as well as the older _locale
+  * Print a message when generating from ARB files if we guess the locale
+    from the file name when there's no explicit @@locale or _locale in the file.
 
 ## 0.12.5
   * Parse Eras in DateFormat.
diff --git a/bin/generate_from_arb.dart b/bin/generate_from_arb.dart
index 5abf723..dd81485 100644
--- a/bin/generate_from_arb.dart
+++ b/bin/generate_from_arb.dart
@@ -8,6 +8,10 @@
  * of ARB files representing translations of messages from the corresponding
  * Dart file. See extract_to_arb.dart and make_hardcoded_translation.dart.
  *
+ * If the ARB file has an @@locale or _locale value, that will be used as
+ * the locale. If not, we will try to figure out the locale from the end of
+ * the file name, e.g. foo_en_GB.arb will be assumed to be in en_GB locale.
+ *
  * This produces a series of files named
  * "messages_<locale>.dart" containing messages for a particular locale
  * and a main import file named "messages_all.dart" which has imports all of
@@ -49,7 +53,7 @@
       defaultsTo: true,
       callback: (x) => useDeferredLoading = x,
       help: 'Generate message code that must be loaded with deferred loading. '
-      'Otherwise, all messages are eagerly loaded.');
+          'Otherwise, all messages are eagerly loaded.');
   parser.parse(args);
   var dartFiles = args.where((x) => x.endsWith("dart")).toList();
   var jsonFiles = args.where((x) => x.endsWith(".arb")).toList();
@@ -92,7 +96,7 @@
   var src = file.readAsStringSync();
   var data = JSON.decode(src);
   data.forEach((k, v) => data[k] = recreateIntlObjects(k, v));
-  var locale = data["_locale"];
+  var locale = data["@@locale"] ?? data["_locale"];
   if (locale != null) {
     locale = locale.translated.string;
   } else {
@@ -102,6 +106,8 @@
     // my_file_fr.arb is locale "fr" or "file_fr".
     var name = path.basenameWithoutExtension(file.path);
     locale = name.split("_").skip(1).join("_");
+    print("No @@locale or _locale field found in $name, "
+        "assuming '$locale' based on the file name.");
   }
   allLocales.add(locale);
 
diff --git a/lib/generate_localized.dart b/lib/generate_localized.dart
index e5c1bc3..9bb4876 100644
--- a/lib/generate_localized.dart
+++ b/lib/generate_localized.dart
@@ -189,7 +189,6 @@
  * function name.
  */
 
-library ${_libraryName(locale)};
 import 'package:$intlImportPath/intl.dart';
 import 'package:$intlImportPath/message_lookup_by_library.dart';
 
@@ -246,8 +245,6 @@
  * delegating to the appropriate library.
  */
 
-library messages_all;
-
 import 'dart:async';
 import 'package:$intlImportPath/message_lookup_by_library.dart';
 import 'package:$intlImportPath/src/intl_helpers.dart';