Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shared/js/manifest_helper.js
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2013-02-06 14:30:36 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2013-02-06 14:30:36 (GMT)
commitf5bac2f1e1a51b83d215a07f9d5d87db337873f3 (patch)
tree15c5f594b1e00c6272552cc5544a1bc757713e34 /shared/js/manifest_helper.js
parentc301ead6bb9c201801400964427b517dafb6a03c (diff)
Get the build to work
Diffstat (limited to 'shared/js/manifest_helper.js')
-rw-r--r--shared/js/manifest_helper.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/shared/js/manifest_helper.js b/shared/js/manifest_helper.js
new file mode 100644
index 0000000..d207603
--- /dev/null
+++ b/shared/js/manifest_helper.js
@@ -0,0 +1,26 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+
+'use strict';
+
+/**
+ * Helper object to access manifest information with locale support.
+ */
+
+var ManifestHelper = function(manifest) {
+ var localeRoot = manifest;
+ var locales = manifest.locales;
+
+ if (locales) {
+ var lang = document.documentElement.lang;
+
+ // If there is a manifest entry for the curret locale, use it, otherwise
+ // fallback on the default manifest.
+ localeRoot = locales[lang] || locales[lang.split('-')[0]] || manifest;
+ }
+
+ // Bind the localized property values.
+ for (var prop in manifest) {
+ this[prop] = localeRoot[prop] || manifest[prop];
+ }
+};