amitdahan / ngx-filesize

filesize.js pipe wrapper for Angular

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use the symbols options for localisation?

joshuaM07 opened this issue · comments

So the way to use the available options is pretty straightforward in Angular.
Here is a snippet of what I have currently:

return new FileSizePipe().transform(bytes, { locale: 'fr-FR' );

where bytes is the file size I wish to transform using the pipe and fr-FR is the language I wish to use. Locale is cool because it automatically deduces what separator to use, but what it doesn't do is change the symbols. Example: Kb, Mb, etc...
In french, it's Ko, Mo, etc...

How can I use the symbols options to define my own set of symbols to be used?

This is what I tried to do but failed miserably:

return new FileSizePipe().transform(bytes, { locale: 'fr-FR', symbols: { Kb: 'Ko', Mb: 'Mo' } } );

Also

const sij: SiJedec = { KB: 'KO', Kb: 'Ko', Gb: 'Go', GB: 'GO' };

return new FileSizePipe().transform(bytes, { locale: 'fr-FR', symbols: sij } );

Can anyone help me please? Thanks in advance.

@amitdahan @majora2007 @richardlnnr