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(id: MassCategory, i18n("Mass"), i18n("Mass"));
19 auto d = UnitCategoryPrivate::get(category: c);
20 KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (mass)", "%1 %2");
21
22 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
23 id: Yottagram,
24 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
33 id: Zettagram,
34 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
43 id: Exagram,
44 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
53 id: Petagram,
54 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
63 id: Teragram,
64 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
73 id: Gigagram,
74 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
83 id: Megagram,
84 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
93 id: Kilogram,
94 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
103 id: Hectogram,
104 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
113 id: Decagram,
114 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
123 id: Gram,
124 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
133 id: Decigram,
134 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
143 id: Centigram,
144 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
153 id: Milligram,
154 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
163 id: Microgram,
164 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
173 id: Nanogram,
174 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
183 id: Picogram,
184 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
193 id: Femtogram,
194 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
203 id: Attogram,
204 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
213 id: Zeptogram,
214 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
223 id: Yoctogram,
224 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
233 id: Ton,
234 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
244 id: Carat,
245 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
255 id: Pound,
256 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
266 id: Ounce,
267 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
276 id: TroyOunce,
277 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
286 id: MassNewton,
287 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
297 id: Kilonewton,
298 multiplier: 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(unit: UnitPrivate::makeUnit(categoryId: MassCategory,
307 id: Stone,
308 multiplier: 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
320

source code of kunitconversion/src/mass.cpp