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

Unified Diff: lib/intl.dart

Issue 1085053002: Adds 'fallback' as a universal fallback locale for messages' (Closed) Base URL: https://github.com/dart-lang/intl.git@master
Patch Set: Created 5 years, 8 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 | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/intl.dart
diff --git a/lib/intl.dart b/lib/intl.dart
index b883f0a02c791826286cedfd9bc3a355d95397db..6ebb568251427bf8767bf16c198eaf2e863cf616 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -188,10 +188,17 @@ class Intl {
/**
* 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 @@ class Intl {
return newLocale;
}
for (var each in
- [canonicalizedLocale(newLocale), shortLocale(newLocale)]) {
+ [canonicalizedLocale(newLocale), shortLocale(newLocale), "fallback"]) {
if (localeExists(each)) {
return each;
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698