2 * Copyright 2012 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 #include "StringForRate.h"
10 #include <SystemCatalog.h>
12 using BPrivate::gSystemCatalog
;
15 #undef B_TRANSLATION_CONTEXT
16 #define B_TRANSLATION_CONTEXT "StringForRate"
23 string_for_rate(double rate
, char* string
, size_t stringSize
, double base
)
25 double kbps
= rate
/ base
;
27 const char* trKey
= B_TRANSLATE_MARK("%d bps");
28 snprintf(string
, stringSize
, gSystemCatalog
.GetString(trKey
,
29 B_TRANSLATION_CONTEXT
), (int)rate
);
32 double mbps
= kbps
/ base
;
34 const char* trKey
= B_TRANSLATE_MARK("%.0f Kbps");
35 snprintf(string
, stringSize
, gSystemCatalog
.GetString(trKey
,
36 B_TRANSLATION_CONTEXT
), kbps
);
39 double gbps
= mbps
/ base
;
41 const char* trKey
= B_TRANSLATE_MARK("%.0f Mbps");
42 snprintf(string
, stringSize
, gSystemCatalog
.GetString(trKey
,
43 B_TRANSLATION_CONTEXT
), mbps
);
46 double tbps
= gbps
/ base
;
48 const char* trKey
= B_TRANSLATE_MARK("%.0f Gbps");
49 snprintf(string
, stringSize
, gSystemCatalog
.GetString(trKey
,
50 B_TRANSLATION_CONTEXT
), gbps
);
53 const char* trKey
= B_TRANSLATE_MARK("%.0f Tbps");
54 snprintf(string
, stringSize
, gSystemCatalog
.GetString(trKey
,
55 B_TRANSLATION_CONTEXT
), tbps
);
60 } // namespace BPrivate