Adds 'fallback' as a universal fallback locale for messages'
BUG=
R=cbracken@google.com
Review URL: https://codereview.chromium.org//1085053002
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02c4d4a..67ced5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.12.2+1
+ * Adds a special locale name "fallback" in verifiedLocale. So if a translation
+ is provided for that locale and has been initialized, anything that doesn't
+ find a closer match will use that locale. This can be used instead of having
+ it default to the text in the original source messages.
+
## 0.12.1
* Adds a DateFormat.parseLoose that accepts mixed case and missing
delimiters when parsing dates. It also allows arbitrary amounts of
diff --git a/lib/intl.dart b/lib/intl.dart
index b883f0a..6ebb568 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -188,10 +188,17 @@
/**
* Given [newLocale] return a locale that we have data for that is similar
* to it, if possible.
+ *
* If [newLocale] is found directly, return it. If it can't be found, look up
* based on just the language (e.g. 'en_CA' -> 'en'). Also accepts '-'
* as a separator and changes it into '_' for lookup, and changes the
* country to uppercase.
+ *
+ * There is a special case that if a locale named "fallback" is present
+ * and has been initialized, this will return that name. This can be useful
+ * for messages where you don't want to just use the text from the original
+ * source code, but wish to have a universal fallback translation.
+ *
* Note that null is interpreted as meaning the default locale, so if
* [newLocale] is null it will be returned.
*/
@@ -210,7 +217,7 @@
return newLocale;
}
for (var each in
- [canonicalizedLocale(newLocale), shortLocale(newLocale)]) {
+ [canonicalizedLocale(newLocale), shortLocale(newLocale), "fallback"]) {
if (localeExists(each)) {
return each;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 0d7627f..5141cf3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: intl
-version: 0.12.2
+version: 0.12.2+1
author: Dart Team <misc@dartlang.org>
description: Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues.
homepage: https://www.dartlang.org