summaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-11-18 12:13:44 +0100
committerVincent Petry <pvince81@owncloud.com>2014-11-18 12:20:01 +0100
commit152da9796b0268069a10b73d65781301a307fcdd (patch)
tree07a5087ff6fac5ccecc4d6547194578e1a305009 /core/js/js.js
parentaf7688ec17c260d3e227393e8e81438fe88b956c (diff)
downloadnextcloud-server-152da9796b0268069a10b73d65781301a307fcdd.tar.gz
nextcloud-server-152da9796b0268069a10b73d65781301a307fcdd.zip
Added function to load translations from JS
For apps that support async translation loading, a new function OC.L10N.load() can be used to asynchronously load the translations for a given app.
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 39e382b544b..eb2f10b51f0 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -253,6 +253,17 @@ var OC={
},
/**
+ * Loads translations for the given app asynchronously.
+ *
+ * @param {String} app app name
+ * @param {Function} callback callback to call after loading
+ * @return {Promise}
+ */
+ addTranslations: function(app, callback) {
+ return OC.L10N.load(app, callback);
+ },
+
+ /**
* Returns the base name of the given path.
* For example for "/abc/somefile.txt" it will return "somefile.txt"
*
@@ -475,6 +486,15 @@ var OC={
return window.matchMedia(media);
}
return false;
+ },
+
+ /**
+ * Returns the user's locale
+ *
+ * @return {String} locale string
+ */
+ getLocale: function() {
+ return $('html').prop('lang');
}
};
@@ -869,9 +889,9 @@ function object(o) {
function initCore() {
/**
- * Set users local to moment.js as soon as possible
+ * Set users locale to moment.js as soon as possible
*/
- moment.locale($('html').prop('lang'));
+ moment.locale(OC.getLocale());
/**