Uh oh!
There was an error while loading. Please reload this page.
Formats file sizes using the user's locale - #11893
Conversation
caugner
commented
Oct 17, 2018
rullzer
commented
Oct 17, 2018
Welcome to the club @caugner |
Unfortunately the new test fails (I tried to run them locally, but I have two possible explanations:
|
|
ChristophWurst
commented
Oct 18, 2018
Awesome first-time contribution ✌️ Thanks a lot 🚀 |
caugner
commented
Oct 18, 2018
@MorrisJobke Yes, looks like we need to convert the Nextcloud locale we get from |
I conducted a short test to see if it suffices to Note that localizing numbers not only affects the decimal separator, but also the digits itself, e.g.: (See https://pastebin.com/URn57qJG for the full test output.) |
@MorrisJobke@danxuliu@skjnldsv Regarding the
|
rullzer
commented
Oct 19, 2018
I would be fine to get this in for now. If phantomjs doesn't play nice then so be it. |
caugner
left a comment
There was a problem hiding this comment.
Need to cover case where getLocale() is undefined.
Uh oh!
There was an error while loading. Please reload this page.
caugner
left a comment
There was a problem hiding this comment.
Took stub fallback value from wrong method.
Uh oh!
There was an error while loading. Please reload this page.
@caugner |
@skjnldsv Afaik we don't need just the primary language here (which Even though "[BCP-47 compliant] language tag" may sound like it only contains the language, it may include e.g. the region. In fact, this is relevant, as number formatting does differ between regions with the same language: 1234.56.toLocaleString('de-DE')// "1.234,56"1234.56.toLocaleString('de-CH')// "1’234.56" |
rullzer
commented
Oct 24, 2018
I took the liberty of rebasing |
ChristophWurst
left a comment
There was a problem hiding this comment.
Nice enhancement. Code looks good and is covered by tests -> 👍
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>
| }); | ||
| it("Returns primary locales as is", function() { | ||
| expect(OC.getCanonicalLocale('de')).toEqual('de'); |
There was a problem hiding this comment.
Rather than calling getCanonicalLocale with the locale as a parameter, set the localeStub to return this
| expect(OC.getCanonicalLocale('de')).toEqual('de'); | |
| localeStub.returns('de'); | |
| expect(OC.getCanonicalLocale()).toEqual('de'); |
| expect(OC.getCanonicalLocale('zu')).toEqual('zu'); | ||
| }); | ||
| it("Returns extended locales with hyphens", function() { | ||
| expect(OC.getCanonicalLocale('az_Cyrl_AZ')).toEqual('az-Cyrl-AZ'); |
There was a problem hiding this comment.
| expect(OC.getCanonicalLocale('az_Cyrl_AZ')).toEqual('az-Cyrl-AZ'); | |
| localeStub.returns('az_Cyrl_AZ'); | |
| expect(OC.getCanonicalLocale()).toEqual('az-Cyrl-AZ'); |
caugner
left a comment
There was a problem hiding this comment.
Need to fix test for getCanonicalLocale
| it("Returns primary locales as is", function() { | ||
| expect(OC.getCanonicalLocale('de')).toEqual('de'); | ||
| expect(OC.getCanonicalLocale('zu')).toEqual('zu'); |
There was a problem hiding this comment.
| expect(OC.getCanonicalLocale('zu')).toEqual('zu'); | |
| localeStub.returns('zu'); | |
| expect(OC.getCanonicalLocale()).toEqual('zu'); |
| }); | ||
| it("Returns extended locales with hyphens", function() { | ||
| expect(OC.getCanonicalLocale('az_Cyrl_AZ')).toEqual('az-Cyrl-AZ'); | ||
| expect(OC.getCanonicalLocale('de_DE')).toEqual('de-DE'); |
There was a problem hiding this comment.
| expect(OC.getCanonicalLocale('de_DE')).toEqual('de-DE'); | |
| localeStub.returns('de_DE'); | |
| expect(OC.getCanonicalLocale()).toEqual('de-DE'); |
Signed-off-by: Claas Augner <git@caugner.de>
MorrisJobke
commented
Oct 24, 2018
There is still an error in the JSUnit tests :'( |
@MorrisJobke Looks like either a test artefact or an unrelated test failing: https://drone.nextcloud.com/nextcloud/server/11798/284 Is there an easy way to trigger another CI run? |
danxuliu
commented
Oct 25, 2018
Unrelated; fix is in #12039 ;-) |
MorrisJobke
commented
Oct 25, 2018
MorrisJobke
commented
Oct 25, 2018
I just had a look and it is exactly the same stack trace -> merging. |
MorrisJobke
commented
Oct 25, 2018
@caugner Thanks for your contribution. You could have a look at other nice starter issues if you wish so: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 I will also invite you to the Nextcloud organization here ;) |



Fixes#7837