KUnitConversion

mass.cpp
1/*
2 * SPDX-FileCopyrightText: 2008-2009 Petri Damstén <damu@iki.fi>
3 * SPDX-FileCopyrightText: 2008 Kristof Bal <kristof.bal@gmail.com>
4 * SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
5 *
6 * SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9#include "mass_p.h"
10#include "unit_p.h"
11
12#include <KLocalizedString>
13
14namespace KUnitConversion
15{
16UnitCategory Mass::makeCategory()
17{
18 auto c = UnitCategoryPrivate::makeCategory(MassCategory, i18n("Mass"), i18n("Mass"));
19 auto d = UnitCategoryPrivate::get(c);
20 KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (mass)", "%1 %2");
21
22 d->addUnit(UnitPrivate::makeUnit(MassCategory,
23 Yottagram,
24 1e+24,
25 i18nc("mass unit symbol", "Yg"),
26 i18nc("unit description in lists", "yottagrams"),
27 i18nc("unit synonyms for matching user input", "yottagram;yottagrams;Yg"),
28 symbolString,
29 ki18nc("amount in units (real)", "%1 yottagrams"),
30 ki18ncp("amount in units (integer)", "%1 yottagram", "%1 yottagrams")));
31
32 d->addUnit(UnitPrivate::makeUnit(MassCategory,
33 Zettagram,
34 1e+21,
35 i18nc("mass unit symbol", "Zg"),
36 i18nc("unit description in lists", "zettagrams"),
37 i18nc("unit synonyms for matching user input", "zettagram;zettagrams;Zg"),
38 symbolString,
39 ki18nc("amount in units (real)", "%1 zettagrams"),
40 ki18ncp("amount in units (integer)", "%1 zettagram", "%1 zettagrams")));
41
42 d->addUnit(UnitPrivate::makeUnit(MassCategory,
43 Exagram,
44 1e+18,
45 i18nc("mass unit symbol", "Eg"),
46 i18nc("unit description in lists", "exagrams"),
47 i18nc("unit synonyms for matching user input", "exagram;exagrams;Eg"),
48 symbolString,
49 ki18nc("amount in units (real)", "%1 exagrams"),
50 ki18ncp("amount in units (integer)", "%1 exagram", "%1 exagrams")));
51
52 d->addUnit(UnitPrivate::makeUnit(MassCategory,
53 Petagram,
54 1e+15,
55 i18nc("mass unit symbol", "Pg"),
56 i18nc("unit description in lists", "petagrams"),
57 i18nc("unit synonyms for matching user input", "petagram;petagrams;Pg"),
58 symbolString,
59 ki18nc("amount in units (real)", "%1 petagrams"),
60 ki18ncp("amount in units (integer)", "%1 petagram", "%1 petagrams")));
61
62 d->addUnit(UnitPrivate::makeUnit(MassCategory,
63 Teragram,
64 1e+12,
65 i18nc("mass unit symbol", "Tg"),
66 i18nc("unit description in lists", "teragrams"),
67 i18nc("unit synonyms for matching user input", "teragram;teragrams;Tg"),
68 symbolString,
69 ki18nc("amount in units (real)", "%1 teragrams"),
70 ki18ncp("amount in units (integer)", "%1 teragram", "%1 teragrams")));
71
72 d->addUnit(UnitPrivate::makeUnit(MassCategory,
73 Gigagram,
74 1e+09,
75 i18nc("mass unit symbol", "Gg"),
76 i18nc("unit description in lists", "gigagrams"),
77 i18nc("unit synonyms for matching user input", "gigagram;gigagrams;Gg"),
78 symbolString,
79 ki18nc("amount in units (real)", "%1 gigagrams"),
80 ki18ncp("amount in units (integer)", "%1 gigagram", "%1 gigagrams")));
81
82 d->addUnit(UnitPrivate::makeUnit(MassCategory,
83 Megagram,
84 1e+06,
85 i18nc("mass unit symbol", "Mg"),
86 i18nc("unit description in lists", "megagrams"),
87 i18nc("unit synonyms for matching user input", "megagram;megagrams;Mg"),
88 symbolString,
89 ki18nc("amount in units (real)", "%1 megagrams"),
90 ki18ncp("amount in units (integer)", "%1 megagram", "%1 megagrams")));
91
92 d->addDefaultUnit(UnitPrivate::makeUnit(MassCategory,
93 Kilogram,
94 1000,
95 i18nc("mass unit symbol", "kg"),
96 i18nc("unit description in lists", "kilograms"),
97 i18nc("unit synonyms for matching user input", "kilogram;kilograms;kg"),
98 symbolString,
99 ki18nc("amount in units (real)", "%1 kilograms"),
100 ki18ncp("amount in units (integer)", "%1 kilogram", "%1 kilograms")));
101
102 d->addUnit(UnitPrivate::makeUnit(MassCategory,
103 Hectogram,
104 100,
105 i18nc("mass unit symbol", "hg"),
106 i18nc("unit description in lists", "hectograms"),
107 i18nc("unit synonyms for matching user input", "hectogram;hectograms;hg"),
108 symbolString,
109 ki18nc("amount in units (real)", "%1 hectograms"),
110 ki18ncp("amount in units (integer)", "%1 hectogram", "%1 hectograms")));
111
112 d->addUnit(UnitPrivate::makeUnit(MassCategory,
113 Decagram,
114 10,
115 i18nc("mass unit symbol", "dag"),
116 i18nc("unit description in lists", "decagrams"),
117 i18nc("unit synonyms for matching user input", "decagram;decagrams;dag"),
118 symbolString,
119 ki18nc("amount in units (real)", "%1 decagrams"),
120 ki18ncp("amount in units (integer)", "%1 decagram", "%1 decagrams")));
121
122 d->addCommonUnit(UnitPrivate::makeUnit(MassCategory,
123 Gram,
124 1,
125 i18nc("mass unit symbol", "g"),
126 i18nc("unit description in lists", "grams"),
127 i18nc("unit synonyms for matching user input", "gram;grams;g"),
128 symbolString,
129 ki18nc("amount in units (real)", "%1 grams"),
130 ki18ncp("amount in units (integer)", "%1 gram", "%1 grams")));
131
132 d->addUnit(UnitPrivate::makeUnit(MassCategory,
133 Decigram,
134 0.1,
135 i18nc("mass unit symbol", "dg"),
136 i18nc("unit description in lists", "decigrams"),
137 i18nc("unit synonyms for matching user input", "decigram;decigrams;dg"),
138 symbolString,
139 ki18nc("amount in units (real)", "%1 decigrams"),
140 ki18ncp("amount in units (integer)", "%1 decigram", "%1 decigrams")));
141
142 d->addUnit(UnitPrivate::makeUnit(MassCategory,
143 Centigram,
144 0.01,
145 i18nc("mass unit symbol", "cg"),
146 i18nc("unit description in lists", "centigrams"),
147 i18nc("unit synonyms for matching user input", "centigram;centigrams;cg"),
148 symbolString,
149 ki18nc("amount in units (real)", "%1 centigrams"),
150 ki18ncp("amount in units (integer)", "%1 centigram", "%1 centigrams")));
151
152 d->addCommonUnit(UnitPrivate::makeUnit(MassCategory,
153 Milligram,
154 0.001,
155 i18nc("mass unit symbol", "mg"),
156 i18nc("unit description in lists", "milligrams"),
157 i18nc("unit synonyms for matching user input", "milligram;milligrams;mg"),
158 symbolString,
159 ki18nc("amount in units (real)", "%1 milligrams"),
160 ki18ncp("amount in units (integer)", "%1 milligram", "%1 milligrams")));
161
162 d->addUnit(UnitPrivate::makeUnit(MassCategory,
163 Microgram,
164 1e-06,
165 i18nc("mass unit symbol", "µg"),
166 i18nc("unit description in lists", "micrograms"),
167 i18nc("unit synonyms for matching user input", "microgram;micrograms;µg;ug"),
168 symbolString,
169 ki18nc("amount in units (real)", "%1 micrograms"),
170 ki18ncp("amount in units (integer)", "%1 microgram", "%1 micrograms")));
171
172 d->addUnit(UnitPrivate::makeUnit(MassCategory,
173 Nanogram,
174 1e-09,
175 i18nc("mass unit symbol", "ng"),
176 i18nc("unit description in lists", "nanograms"),
177 i18nc("unit synonyms for matching user input", "nanogram;nanograms;ng"),
178 symbolString,
179 ki18nc("amount in units (real)", "%1 nanograms"),
180 ki18ncp("amount in units (integer)", "%1 nanogram", "%1 nanograms")));
181
182 d->addUnit(UnitPrivate::makeUnit(MassCategory,
183 Picogram,
184 1e-12,
185 i18nc("mass unit symbol", "pg"),
186 i18nc("unit description in lists", "picograms"),
187 i18nc("unit synonyms for matching user input", "picogram;picograms;pg"),
188 symbolString,
189 ki18nc("amount in units (real)", "%1 picograms"),
190 ki18ncp("amount in units (integer)", "%1 picogram", "%1 picograms")));
191
192 d->addUnit(UnitPrivate::makeUnit(MassCategory,
193 Femtogram,
194 1e-15,
195 i18nc("mass unit symbol", "fg"),
196 i18nc("unit description in lists", "femtograms"),
197 i18nc("unit synonyms for matching user input", "femtogram;femtograms;fg"),
198 symbolString,
199 ki18nc("amount in units (real)", "%1 femtograms"),
200 ki18ncp("amount in units (integer)", "%1 femtogram", "%1 femtograms")));
201
202 d->addUnit(UnitPrivate::makeUnit(MassCategory,
203 Attogram,
204 1e-18,
205 i18nc("mass unit symbol", "ag"),
206 i18nc("unit description in lists", "attograms"),
207 i18nc("unit synonyms for matching user input", "attogram;attograms;ag"),
208 symbolString,
209 ki18nc("amount in units (real)", "%1 attograms"),
210 ki18ncp("amount in units (integer)", "%1 attogram", "%1 attograms")));
211
212 d->addUnit(UnitPrivate::makeUnit(MassCategory,
213 Zeptogram,
214 1e-21,
215 i18nc("mass unit symbol", "zg"),
216 i18nc("unit description in lists", "zeptograms"),
217 i18nc("unit synonyms for matching user input", "zeptogram;zeptograms;zg"),
218 symbolString,
219 ki18nc("amount in units (real)", "%1 zeptograms"),
220 ki18ncp("amount in units (integer)", "%1 zeptogram", "%1 zeptograms")));
221
222 d->addUnit(UnitPrivate::makeUnit(MassCategory,
223 Yoctogram,
224 1e-24,
225 i18nc("mass unit symbol", "yg"),
226 i18nc("unit description in lists", "yoctograms"),
227 i18nc("unit synonyms for matching user input", "yoctogram;yoctograms;yg"),
228 symbolString,
229 ki18nc("amount in units (real)", "%1 yoctograms"),
230 ki18ncp("amount in units (integer)", "%1 yoctogram", "%1 yoctograms")));
231
232 d->addCommonUnit(UnitPrivate::makeUnit(MassCategory,
233 Ton,
234 1e+06,
235 i18nc("mass unit symbol", "t"),
236 i18nc("unit description in lists", "tons"),
237 i18nc("unit synonyms for matching user input", "ton;tons;t;tonne;tonnes"), // TODO Fix! Tonne == Metric Ton == Mg
238 symbolString,
239 ki18nc("amount in units (real)", "%1 tons"),
240 ki18ncp("amount in units (integer)", "%1 ton", "%1 tons")));
241
242 // I guess it's useful...
243 d->addUnit(UnitPrivate::makeUnit(MassCategory,
244 Carat,
245 0.2,
246 i18nc("mass unit symbol", "CD"),
247 i18nc("unit description in lists", "carats"),
248 i18nc("unit synonyms for matching user input", "carat;carats;CD;ct"),
249 symbolString,
250 ki18nc("amount in units (real)", "%1 carats"),
251 ki18ncp("amount in units (integer)", "%1 carat", "%1 carats")));
252
253 // http://en.wikipedia.org/wiki/Pound_(mass)#International_pound
254 d->addCommonUnit(UnitPrivate::makeUnit(MassCategory,
255 Pound,
256 453.592,
257 i18nc("mass unit symbol", "lb"),
258 i18nc("unit description in lists", "pounds"),
259 i18nc("unit synonyms for matching user input", "pound;pounds;lb;lbs"),
260 symbolString,
261 ki18nc("amount in units (real)", "%1 pounds"),
262 ki18ncp("amount in units (integer)", "%1 pound", "%1 pounds")));
263
264 // International avoirdupois ounce
265 d->addCommonUnit(UnitPrivate::makeUnit(MassCategory,
266 Ounce,
267 28.3495,
268 i18nc("mass unit symbol", "oz"),
269 i18nc("unit description in lists", "ounces"),
270 i18nc("unit synonyms for matching user input", "ounce;ounces;oz"),
271 symbolString,
272 ki18nc("amount in units (real)", "%1 ounces"),
273 ki18ncp("amount in units (integer)", "%1 ounce", "%1 ounces")));
274
275 d->addUnit(UnitPrivate::makeUnit(MassCategory,
276 TroyOunce,
277 31.1035,
278 i18nc("mass unit symbol", "t oz"),
279 i18nc("unit description in lists", "troy ounces"),
280 i18nc("unit synonyms for matching user input", "troy ounce;troy ounces;t oz"),
281 symbolString,
282 ki18nc("amount in units (real)", "%1 troy ounces"),
283 ki18ncp("amount in units (integer)", "%1 troy ounce", "%1 troy ounces")));
284
285 d->addUnit(UnitPrivate::makeUnit(MassCategory,
286 MassNewton,
287 101.937,
288 i18nc("mass unit symbol", "N"),
289 i18nc("unit description in lists", "newtons"),
290 i18nc("unit synonyms for matching user input", "newton;newtons;N"),
291 symbolString,
292 ki18nc("amount in units (real)", "%1 newtons"),
293 ki18ncp("amount in units (integer)", "%1 newton", "%1 newtons")));
294
295 // used a lot in industry (aircraft engines for example)
296 d->addUnit(UnitPrivate::makeUnit(MassCategory,
297 Kilonewton,
298 101937,
299 i18nc("mass unit symbol", "kN"),
300 i18nc("unit description in lists", "kilonewton"),
301 i18nc("unit synonyms for matching user input", "kilonewton;kilonewton;kN"),
302 symbolString,
303 ki18nc("amount in units (real)", "%1 kilonewton"),
304 ki18ncp("amount in units (integer)", "%1 kilonewton", "%1 kilonewton")));
305
306 d->addUnit(UnitPrivate::makeUnit(MassCategory,
307 Stone,
308 6350.29318,
309 i18nc("mass unit symbol", "st"),
310 i18nc("unit description in lists", "stone"),
311 i18nc("unit synonyms for matching user input", "stone;st"),
312 symbolString,
313 ki18nc("amount in units (real)", "%1 stone"),
314 ki18ncp("amount in units (integer)", "%1 stone", "%1 stone")));
315
316 return c;
317}
318
319} // KUnitConversion namespace
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.