diff options
author | Claas Augner <git@caugner.de> | 2018-10-17 21:43:37 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-24 09:18:39 +0200 |
commit | 00b8be60f20b0f75918929c9ae569122b229e281 (patch) | |
tree | 74b2d9dd998cd6afb68636404f7ea262ea59656d /core/js/js.js | |
parent | 7c0cd4f9ff22d1b94176079dca152b2f56ff0c88 (diff) | |
download | nextcloud-server-00b8be60f20b0f75918929c9ae569122b229e281.tar.gz nextcloud-server-00b8be60f20b0f75918929c9ae569122b229e281.zip |
humanFileSize: use toLocaleString
humanFileSize: add test with locale
humanFileSize: use canonical locale
humanFileSize: skip test w/o toLocaleString support
humanFileSize: stub getCanonicalLocale
OC.getCanonicalLocale: cover undefined case
humanFileSize: fix getCanonicalLocale stub
Signed-off-by: Claas Augner <git@caugner.de>
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index 12c47d546c1..880b986e17b 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -771,6 +771,16 @@ var OCP = {}, }, /** + * Returns the user's locale as a BCP 47 compliant language tag + * + * @return {String} locale string + */ + getCanonicalLocale: function() { + var locale = this.getLocale(); + return typeof locale === 'string' ? locale.replace(/_/g, '-') : locale; + }, + + /** * Returns the user's locale * * @return {String} locale string @@ -1843,6 +1853,9 @@ function humanFileSize(size, skipSmallSizes) { else if(relativeSize.substr(relativeSize.length-2,2)==='.0'){ relativeSize=relativeSize.substr(0,relativeSize.length-2); } + else{ + relativeSize = parseFloat(relativeSize).toLocaleString(OC.getCanonicalLocale()); + } return relativeSize + ' ' + readableFormat; } |