Commit 76af5dab authored by Philip Withnall's avatar Philip Withnall

Merge branch '1625-unbreakable-space-needed-when-showing-size-of-folder-file' into 'master'

Resolve "Unbreakable space needed when showing size of folder/file"

Closes #1625

See merge request !548
parents 8109eaae 3da40e90
Pipeline #50438 failed with stages
in 15 minutes and 59 seconds
...@@ -2378,36 +2378,60 @@ g_format_size_full (guint64 size, ...@@ -2378,36 +2378,60 @@ g_format_size_full (guint64 size,
const struct Format formats[4][6] = { const struct Format formats[4][6] = {
{ {
{ KILOBYTE_FACTOR, N_("%.1f kB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ MEGABYTE_FACTOR, N_("%.1f MB") }, { KILOBYTE_FACTOR, N_("%.1f kB") },
{ GIGABYTE_FACTOR, N_("%.1f GB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TERABYTE_FACTOR, N_("%.1f TB") }, { MEGABYTE_FACTOR, N_("%.1f MB") },
{ PETABYTE_FACTOR, N_("%.1f PB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXABYTE_FACTOR, N_("%.1f EB") } { GIGABYTE_FACTOR, N_("%.1f GB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TERABYTE_FACTOR, N_("%.1f TB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ PETABYTE_FACTOR, N_("%.1f PB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXABYTE_FACTOR, N_("%.1f EB") }
}, },
{ {
{ KIBIBYTE_FACTOR, N_("%.1f KiB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ MEBIBYTE_FACTOR, N_("%.1f MiB") }, { KIBIBYTE_FACTOR, N_("%.1f KiB") },
{ GIBIBYTE_FACTOR, N_("%.1f GiB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TEBIBYTE_FACTOR, N_("%.1f TiB") }, { MEBIBYTE_FACTOR, N_("%.1f MiB") },
{ PEBIBYTE_FACTOR, N_("%.1f PiB") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXBIBYTE_FACTOR, N_("%.1f EiB") } { GIBIBYTE_FACTOR, N_("%.1f GiB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TEBIBYTE_FACTOR, N_("%.1f TiB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ PEBIBYTE_FACTOR, N_("%.1f PiB") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXBIBYTE_FACTOR, N_("%.1f EiB") }
}, },
{ {
{ KILOBYTE_FACTOR, N_("%.1f kb") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ MEGABYTE_FACTOR, N_("%.1f Mb") }, { KILOBYTE_FACTOR, N_("%.1f kb") },
{ GIGABYTE_FACTOR, N_("%.1f Gb") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TERABYTE_FACTOR, N_("%.1f Tb") }, { MEGABYTE_FACTOR, N_("%.1f Mb") },
{ PETABYTE_FACTOR, N_("%.1f Pb") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXABYTE_FACTOR, N_("%.1f Eb") } { GIGABYTE_FACTOR, N_("%.1f Gb") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TERABYTE_FACTOR, N_("%.1f Tb") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ PETABYTE_FACTOR, N_("%.1f Pb") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXABYTE_FACTOR, N_("%.1f Eb") }
}, },
{ {
{ KIBIBYTE_FACTOR, N_("%.1f Kib") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ MEBIBYTE_FACTOR, N_("%.1f Mib") }, { KIBIBYTE_FACTOR, N_("%.1f Kib") },
{ GIBIBYTE_FACTOR, N_("%.1f Gib") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TEBIBYTE_FACTOR, N_("%.1f Tib") }, { MEBIBYTE_FACTOR, N_("%.1f Mib") },
{ PEBIBYTE_FACTOR, N_("%.1f Pib") }, /* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXBIBYTE_FACTOR, N_("%.1f Eib") } { GIBIBYTE_FACTOR, N_("%.1f Gib") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ TEBIBYTE_FACTOR, N_("%.1f Tib") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ PEBIBYTE_FACTOR, N_("%.1f Pib") },
/* Translators: Keep the no-break space between %.1f and the unit symbol */
{ EXBIBYTE_FACTOR, N_("%.1f Eib") }
} }
}; };
......
...@@ -538,57 +538,58 @@ test_format_size_for_display (void) ...@@ -538,57 +538,58 @@ test_format_size_for_display (void)
check_string (g_format_size (0), "0 bytes"); check_string (g_format_size (0), "0 bytes");
check_string (g_format_size (1), "1 byte"); check_string (g_format_size (1), "1 byte");
check_string (g_format_size (2), "2 bytes"); check_string (g_format_size (2), "2 bytes");
check_string (g_format_size (1000ULL), "1.0 kB"); /* '\302\240' is a no-break space, to keep quantity and unit symbol together at line breaks*/
check_string (g_format_size (1000ULL * 1000), "1.0 MB"); check_string (g_format_size (1000ULL), "1.0\302\240kB");
check_string (g_format_size (1000ULL * 1000 * 1000), "1.0 GB"); check_string (g_format_size (1000ULL * 1000), "1.0\302\240MB");
check_string (g_format_size (1000ULL * 1000 * 1000 * 1000), "1.0 TB"); check_string (g_format_size (1000ULL * 1000 * 1000), "1.0\302\240GB");
check_string (g_format_size (1000ULL * 1000 * 1000 * 1000 * 1000), "1.0 PB"); check_string (g_format_size (1000ULL * 1000 * 1000 * 1000), "1.0\302\240TB");
check_string (g_format_size (1000ULL * 1000 * 1000 * 1000 * 1000 * 1000), "1.0 EB"); check_string (g_format_size (1000ULL * 1000 * 1000 * 1000 * 1000), "1.0\302\240PB");
check_string (g_format_size (1000ULL * 1000 * 1000 * 1000 * 1000 * 1000), "1.0\302\240EB");
check_string (g_format_size_full (0, G_FORMAT_SIZE_IEC_UNITS), "0 bytes"); check_string (g_format_size_full (0, G_FORMAT_SIZE_IEC_UNITS), "0 bytes");
check_string (g_format_size_full (1, G_FORMAT_SIZE_IEC_UNITS), "1 byte"); check_string (g_format_size_full (1, G_FORMAT_SIZE_IEC_UNITS), "1 byte");
check_string (g_format_size_full (2, G_FORMAT_SIZE_IEC_UNITS), "2 bytes"); check_string (g_format_size_full (2, G_FORMAT_SIZE_IEC_UNITS), "2 bytes");
check_string (g_format_size_full (2048ULL, G_FORMAT_SIZE_IEC_UNITS), "2.0 KiB"); check_string (g_format_size_full (2048ULL, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240KiB");
check_string (g_format_size_full (2048ULL * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 MiB"); check_string (g_format_size_full (2048ULL * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240MiB");
check_string (g_format_size_full (2048ULL * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 GiB"); check_string (g_format_size_full (2048ULL * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240GiB");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 TiB"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240TiB");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 PiB"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240PiB");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0 EiB"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240EiB");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_IEC_UNITS), "227.4 MiB"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_IEC_UNITS), "227.4\302\240MiB");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_DEFAULT), "238.5 MB"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_DEFAULT), "238.5\302\240MB");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_LONG_FORMAT), "238.5 MB (238472938 bytes)"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_LONG_FORMAT), "238.5\302\240MB (238472938 bytes)");
check_string (g_format_size_full (0, G_FORMAT_SIZE_BITS), "0 bits"); check_string (g_format_size_full (0, G_FORMAT_SIZE_BITS), "0 bits");
check_string (g_format_size_full (1, G_FORMAT_SIZE_BITS), "1 bit"); check_string (g_format_size_full (1, G_FORMAT_SIZE_BITS), "1 bit");
check_string (g_format_size_full (2, G_FORMAT_SIZE_BITS), "2 bits"); check_string (g_format_size_full (2, G_FORMAT_SIZE_BITS), "2 bits");
check_string (g_format_size_full (2000ULL, G_FORMAT_SIZE_BITS), "2.0 kb"); check_string (g_format_size_full (2000ULL, G_FORMAT_SIZE_BITS), "2.0\302\240kb");
check_string (g_format_size_full (2000ULL * 1000, G_FORMAT_SIZE_BITS), "2.0 Mb"); check_string (g_format_size_full (2000ULL * 1000, G_FORMAT_SIZE_BITS), "2.0\302\240Mb");
check_string (g_format_size_full (2000ULL * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0 Gb"); check_string (g_format_size_full (2000ULL * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0\302\240Gb");
check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0 Tb"); check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0\302\240Tb");
check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0 Pb"); check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0\302\240Pb");
check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0 Eb"); check_string (g_format_size_full (2000ULL * 1000 * 1000 * 1000 * 1000 * 1000, G_FORMAT_SIZE_BITS), "2.0\302\240Eb");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS), "238.5 Mb"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS), "238.5\302\240Mb");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_LONG_FORMAT), "238.5 Mb (238472938 bits)"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_LONG_FORMAT), "238.5\302\240Mb (238472938 bits)");
check_string (g_format_size_full (0, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "0 bits"); check_string (g_format_size_full (0, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "0 bits");
check_string (g_format_size_full (1, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "1 bit"); check_string (g_format_size_full (1, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "1 bit");
check_string (g_format_size_full (2, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2 bits"); check_string (g_format_size_full (2, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2 bits");
check_string (g_format_size_full (2048ULL, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Kib"); check_string (g_format_size_full (2048ULL, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Kib");
check_string (g_format_size_full (2048ULL * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Mib"); check_string (g_format_size_full (2048ULL * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Mib");
check_string (g_format_size_full (2048ULL * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Gib"); check_string (g_format_size_full (2048ULL * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Gib");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Tib"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Tib");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Pib"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Pib");
check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0 Eib"); check_string (g_format_size_full (2048ULL * 1024 * 1024 * 1024 * 1024 * 1024, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "2.0\302\240Eib");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "227.4 Mib"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS), "227.4\302\240Mib");
check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS | G_FORMAT_SIZE_LONG_FORMAT), "227.4 Mib (238472938 bits)"); check_string (g_format_size_full (238472938, G_FORMAT_SIZE_BITS | G_FORMAT_SIZE_IEC_UNITS | G_FORMAT_SIZE_LONG_FORMAT), "227.4\302\240Mib (238472938 bits)");
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment