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

Unified Diff: pkg/intl/intl_browser.dart

Issue 10907266: Find the system locale from the browser or OS (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/intl.dart ('k') | pkg/intl/intl_standalone.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/intl_browser.dart
===================================================================
--- pkg/intl/intl_browser.dart (revision 0)
+++ pkg/intl/intl_browser.dart (revision 0)
@@ -0,0 +1,29 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * This provides facilities for Internationalization that are only available
+ * when running in the web browser. You should import only one of this or
+ * intl_standalone.dart. Right now the only thing provided here is the
+ * ability to find the default locale from the browser.
+ */
+
+#library("intl_browser");
+
+#import("dart:html");
+#import("intl.dart");
+
+// TODO(alanknight): The need to do this by forcing the user to specially
+// import a particular library is a horrible hack, only done because there
+// seems to be no graceful way to do this at all. Either mirror access on
+// dart2js or the ability to do spawnUri in the browser would be promising
+// as ways to get rid of this requirement.
+/**
+ * Find the system locale, accessed as window.navigator.language, and
+ * set it as the default for internationalization operations in the
+ * [Intl.systemLocale] variable.
+ */
+Future<String> findSystemLocale() {
+ Intl.systemLocale = window.navigator.language.replaceFirst("-","_");
+}
« no previous file with comments | « pkg/intl/intl.dart ('k') | pkg/intl/intl_standalone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698