-1

QLocale::formattedDataSize 总是返回英文量化单位。

4

1 回答 1

2

从qlocale_data_p.h的源代码可以看出,这些单位已被清楚地翻译。

byte_unit_data此私有标头定义了一个以以下内容命名的数组作为字符:

byteskb; mb; gb; tb; pb; ebkib; mib; gib; tib; pib; eibbytegrepebajtባይትኪባ;ሜጋባይት;ጊባ;ጊባ; pb; eb eb to; eb the; ebবাইটকিঃ;মেঃ;গিঃ;টেঃ; pb; ebbaytbyte-akoktedoùko; mo; mo; go; to; to; po; po; eokio; mio; mio; gio; tio; tio; pio; eio uis uiss;千字节字节;兆字节;吉字节;太字节;PB;EB位元组bajtovibajtybaiiddbýtKB;MB;GB;TB;PB;EBtavutkt;Mt;Gt;Tt;Pt;EtKit;Mit;Git; tit; pit; eitoctetsbaidht;მბაიტი;გბაიტი; pb; ebbytesબાઇટબાઇટבבइटbájtbætibeArtaバイト.;ಮೆ.;ಮೆ. mi us; gi;试ئ;ممold;گگا;گگگٽز;ٽq;ٽq; pb; pb; ebබයිට්කිබ{0};මෙබ{0};ගිබ{0};ගිබ{0};ගිබ{0};ටෙබ{0}; pb; pb; ebkilobaiti; terabaiti {0};PB;ebபைட்கள்; ఎమ్‌బి;జీబీ;టీబీ; pb; ebไบต์paitikb e {0}; mb a {0}; gb e {0}; gb e {0}; 0};MiB`e {

...

因此,您必须使用正确的语言环境(从您的用户个人资料中的位置,我假设它是Russian)和格式QLocale::DataSizeTraditionalFormat如下:

QLocale l(QLocale::Russian, QLocale::Russia);

l.formattedDataSize(154, 2, QLocale::DataSizeTraditionalFormat);        // "154 байты"
l.formattedDataSize(19324, 2, QLocale::DataSizeTraditionalFormat);      // "18,87 кБ"
l.formattedDataSize(125839324, 2, QLocale::DataSizeTraditionalFormat);  // "120,01 МБ"
于 2018-08-27T21:12:01.647 回答