Byte Converter

The ByteConverterPipe is an Angular pipe designed for converting numeric values representing file sizes into a human-readable format. It includes functionality for unit conversion (BYTE, KB, MB, GB, TB) and supports internationalization (i18n) with translations for multiple languages.

Language Support

The pipe automatically adapts to the user's browser language. In the event that the browser language is not supported, English serves as the default language. If you encounter language-related issues or wish to contribute translations, please create an issue on GitHub.

Usage

Below is an example demonstrating the usage of the ByteConverterPipe in English:

import {ByteConverterPipe} from 'ngx-lift';

@Component({
  standalone: true,
  imports: [ByteConverterPipe],
  template: `
    <p>{{ 104.89 | byteConverter }}</p>
    <!-- Input fileSize: 104.89 bytes, Output: "104.89 B" -->

    <p>{{ 1044.89 | byteConverter }}</p>
    <!-- Input fileSize: 1044.89 bytes, Output: "1.02 KB" -->

    <p>{{ 2 * 1024 * 1024 | byteConverter }}</p>
    <!-- Input fileSize: 2 * 1024 * 1024 bytes, Output: "2 MB" -->

    <p>{{ 2.89 * 1024 * 1024 * 1024 * 1024 | byteConverter }}</p>
    <!-- Input fileSize: 2.89 * 1024 * 1024 * 1024 * 1024 bytes, Output: "2.89 TB" -->
  `
})
export class ByteConverterPipeDemoComponent { }