1/*
2 * SPDX-FileCopyrightText: 2007-2009 Petri Damstén <damu@iki.fi>
3 * SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#include "length_p.h"
9#include "unit_p.h"
10
11#include <KLocalizedString>
12
13namespace KUnitConversion
14{
15
16UnitCategory Length::makeCategory()
17{
18 auto c = UnitCategoryPrivate::makeCategory(id: LengthCategory, i18n("Length"), i18n("Length"));
19 auto d = UnitCategoryPrivate::get(category: c);
20 KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (length", "%1 %2");
21
22 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
23 id: Yottameter,
24 multiplier: 1e+24,
25 i18nc("length unit symbol", "Ym"),
26 i18nc("unit description in lists", "yottameters"),
27 i18nc("unit synonyms for matching user input", "yottameter;yottameters;Ym"),
28 symbolString,
29 ki18nc("amount in units (real)", "%1 yottameters"),
30 ki18ncp("amount in units (integer)", "%1 yottameter", "%1 yottameters")));
31
32 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
33 id: Zettameter,
34 multiplier: 1e+21,
35 i18nc("length unit symbol", "Zm"),
36 i18nc("unit description in lists", "zettameters"),
37 i18nc("unit synonyms for matching user input", "zettameter;zettameters;Zm"),
38 symbolString,
39 ki18nc("amount in units (real)", "%1 zettameters"),
40 ki18ncp("amount in units (integer)", "%1 zettameter", "%1 zettameters")));
41
42 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
43 id: Exameter,
44 multiplier: 1e+18,
45 i18nc("length unit symbol", "Em"),
46 i18nc("unit description in lists", "exameters"),
47 i18nc("unit synonyms for matching user input", "exameter;exameters;Em"),
48 symbolString,
49 ki18nc("amount in units (real)", "%1 exameters"),
50 ki18ncp("amount in units (integer)", "%1 exameter", "%1 exameters")));
51
52 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
53 id: Petameter,
54 multiplier: 1e+15,
55 i18nc("length unit symbol", "Pm"),
56 i18nc("unit description in lists", "petameters"),
57 i18nc("unit synonyms for matching user input", "petameter;petameters;Pm"),
58 symbolString,
59 ki18nc("amount in units (real)", "%1 petameters"),
60 ki18ncp("amount in units (integer)", "%1 petameter", "%1 petameters")));
61
62 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
63 id: Terameter,
64 multiplier: 1e+12,
65 i18nc("length unit symbol", "Tm"),
66 i18nc("unit description in lists", "terameters"),
67 i18nc("unit synonyms for matching user input", "terameter;terameters;Tm"),
68 symbolString,
69 ki18nc("amount in units (real)", "%1 terameters"),
70 ki18ncp("amount in units (integer)", "%1 terameter", "%1 terameters")));
71
72 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
73 id: Gigameter,
74 multiplier: 1e+09,
75 i18nc("length unit symbol", "Gm"),
76 i18nc("unit description in lists", "gigameters"),
77 i18nc("unit synonyms for matching user input", "gigameter;gigameters;Gm"),
78 symbolString,
79 ki18nc("amount in units (real)", "%1 gigameters"),
80 ki18ncp("amount in units (integer)", "%1 gigameter", "%1 gigameters")));
81
82 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
83 id: Megameter,
84 multiplier: 1e+06,
85 i18nc("length unit symbol", "Mm"),
86 i18nc("unit description in lists", "megameters"),
87 i18nc("unit synonyms for matching user input", "megameter;megameters;Mm"),
88 symbolString,
89 ki18nc("amount in units (real)", "%1 megameters"),
90 ki18ncp("amount in units (integer)", "%1 megameter", "%1 megameters")));
91
92 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
93 id: Kilometer,
94 multiplier: 1000,
95 i18nc("length unit symbol", "km"),
96 i18nc("unit description in lists", "kilometers"),
97 i18nc("unit synonyms for matching user input", "kilometer;kilometers;km"),
98 symbolString,
99 ki18nc("amount in units (real)", "%1 kilometers"),
100 ki18ncp("amount in units (integer)", "%1 kilometer", "%1 kilometers")));
101
102 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
103 id: Hectometer,
104 multiplier: 100,
105 i18nc("length unit symbol", "hm"),
106 i18nc("unit description in lists", "hectometers"),
107 i18nc("unit synonyms for matching user input", "hectometer;hectometers;hm"),
108 symbolString,
109 ki18nc("amount in units (real)", "%1 hectometers"),
110 ki18ncp("amount in units (integer)", "%1 hectometer", "%1 hectometers")));
111
112 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
113 id: Decameter,
114 multiplier: 10,
115 i18nc("length unit symbol", "dam"),
116 i18nc("unit description in lists", "decameters"),
117 i18nc("unit synonyms for matching user input", "decameter;decameters;dam"),
118 symbolString,
119 ki18nc("amount in units (real)", "%1 decameters"),
120 ki18ncp("amount in units (integer)", "%1 decameter", "%1 decameters")));
121
122 d->addDefaultUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
123 id: Meter,
124 multiplier: 1,
125 i18nc("length unit symbol", "m"),
126 i18nc("unit description in lists", "meters"),
127 i18nc("unit synonyms for matching user input", "meter;meters;m"),
128 symbolString,
129 ki18nc("amount in units (real)", "%1 meters"),
130 ki18ncp("amount in units (integer)", "%1 meter", "%1 meters")));
131
132 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
133 id: Decimeter,
134 multiplier: 0.1,
135 i18nc("length unit symbol", "dm"),
136 i18nc("unit description in lists", "decimeters"),
137 i18nc("unit synonyms for matching user input", "decimeter;decimeters;dm"),
138 symbolString,
139 ki18nc("amount in units (real)", "%1 decimeters"),
140 ki18ncp("amount in units (integer)", "%1 decimeter", "%1 decimeters")));
141
142 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
143 id: Centimeter,
144 multiplier: 0.01,
145 i18nc("length unit symbol", "cm"),
146 i18nc("unit description in lists", "centimeters"),
147 i18nc("unit synonyms for matching user input", "centimeter;centimeters;cm"),
148 symbolString,
149 ki18nc("amount in units (real)", "%1 centimeters"),
150 ki18ncp("amount in units (integer)", "%1 centimeter", "%1 centimeters")));
151
152 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
153 id: Millimeter,
154 multiplier: 0.001,
155 i18nc("length unit symbol", "mm"),
156 i18nc("unit description in lists", "millimeters"),
157 i18nc("unit synonyms for matching user input", "millimeter;millimeters;mm"),
158 symbolString,
159 ki18nc("amount in units (real)", "%1 millimeters"),
160 ki18ncp("amount in units (integer)", "%1 millimeter", "%1 millimeters")));
161
162 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
163 id: Micrometer,
164 multiplier: 1e-06,
165 i18nc("length unit symbol", "µm"),
166 i18nc("unit description in lists", "micrometers"),
167 i18nc("unit synonyms for matching user input", "micrometer;micrometers;µm;um"),
168 symbolString,
169 ki18nc("amount in units (real)", "%1 micrometers"),
170 ki18ncp("amount in units (integer)", "%1 micrometer", "%1 micrometers")));
171
172 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
173 id: Nanometer,
174 multiplier: 1e-09,
175 i18nc("length unit symbol", "nm"),
176 i18nc("unit description in lists", "nanometers"),
177 i18nc("unit synonyms for matching user input", "nanometer;nanometers;nm"),
178 symbolString,
179 ki18nc("amount in units (real)", "%1 nanometers"),
180 ki18ncp("amount in units (integer)", "%1 nanometer", "%1 nanometers")));
181
182 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
183 id: Angstrom,
184 multiplier: 1e-10,
185 i18nc("length unit symbol", "Å"),
186 i18nc("unit description in lists", "Ångström"),
187 i18nc("unit synonyms for matching user input", "Ångström;Ångstrom;Angström;Angstrom;Ångströms;Ångstroms;Angströms;Angstroms;Å"),
188 symbolString,
189 ki18nc("amount in units (real)", "%1 Ångströms"),
190 ki18ncp("amount in units (integer)", "%1 Ångström", "%1 Ångströms")));
191
192 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
193 id: Picometer,
194 multiplier: 1e-12,
195 i18nc("length unit symbol", "pm"),
196 i18nc("unit description in lists", "picometers"),
197 i18nc("unit synonyms for matching user input", "picometer;picometers;pm"),
198 symbolString,
199 ki18nc("amount in units (real)", "%1 picometers"),
200 ki18ncp("amount in units (integer)", "%1 picometer", "%1 picometers")));
201
202 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
203 id: Femtometer,
204 multiplier: 1e-15,
205 i18nc("length unit symbol", "fm"),
206 i18nc("unit description in lists", "femtometers"),
207 i18nc("unit synonyms for matching user input", "femtometer;femtometers;fm"),
208 symbolString,
209 ki18nc("amount in units (real)", "%1 femtometers"),
210 ki18ncp("amount in units (integer)", "%1 femtometer", "%1 femtometers")));
211
212 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
213 id: Attometer,
214 multiplier: 1e-18,
215 i18nc("length unit symbol", "am"),
216 i18nc("unit description in lists", "attometers"),
217 i18nc("unit synonyms for matching user input", "attometer;attometers;am"),
218 symbolString,
219 ki18nc("amount in units (real)", "%1 attometers"),
220 ki18ncp("amount in units (integer)", "%1 attometer", "%1 attometers")));
221
222 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
223 id: Zeptometer,
224 multiplier: 1e-21,
225 i18nc("length unit symbol", "zm"),
226 i18nc("unit description in lists", "zeptometers"),
227 i18nc("unit synonyms for matching user input", "zeptometer;zeptometers;zm"),
228 symbolString,
229 ki18nc("amount in units (real)", "%1 zeptometers"),
230 ki18ncp("amount in units (integer)", "%1 zeptometer", "%1 zeptometers")));
231
232 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
233 id: Yoctometer,
234 multiplier: 1e-24,
235 i18nc("length unit symbol", "ym"),
236 i18nc("unit description in lists", "yoctometers"),
237 i18nc("unit synonyms for matching user input", "yoctometer;yoctometers;ym"),
238 symbolString,
239 ki18nc("amount in units (real)", "%1 yoctometers"),
240 ki18ncp("amount in units (integer)", "%1 yoctometer", "%1 yoctometers")));
241
242 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
243 id: Inch,
244 multiplier: 0.0254,
245 i18nc("length unit symbol", "in"),
246 i18nc("unit description in lists", "inches"),
247 i18nc("unit synonyms for matching user input", "inch;inches;in;\""),
248 symbolString,
249 ki18nc("amount in units (real)", "%1 inches"),
250 ki18ncp("amount in units (integer)", "%1 inch", "%1 inches")));
251
252 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
253 id: Thou,
254 multiplier: 0.0000254,
255 i18nc("length unit symbol", "thou"),
256 i18nc("unit description in lists", "thousandths of an inch"),
257 i18nc("unit synonyms for matching user input", "thou;mil;point;thousandth of an inch;thousandths of an inch"),
258 symbolString,
259 ki18nc("amount in units (real)", "%1 thousandths of an inch"),
260 ki18ncp("amount in units (integer)", "%1 thousandth of an inch", "%1 thousandths of an inch")));
261
262 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
263 id: Foot,
264 multiplier: 0.3048,
265 i18nc("length unit symbol", "ft"),
266 i18nc("unit description in lists", "feet"),
267 i18nc("unit synonyms for matching user input", "foot;feet;ft"),
268 symbolString,
269 ki18nc("amount in units (real)", "%1 feet"),
270 ki18ncp("amount in units (integer)", "%1 foot", "%1 feet")));
271
272 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
273 id: Yard,
274 multiplier: 0.9144,
275 i18nc("length unit symbol", "yd"),
276 i18nc("unit description in lists", "yards"),
277 i18nc("unit synonyms for matching user input", "yard;yards;yd"),
278 symbolString,
279 ki18nc("amount in units (real)", "%1 yards"),
280 ki18ncp("amount in units (integer)", "%1 yard", "%1 yards")));
281
282 d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
283 id: Mile,
284 multiplier: 1609.34,
285 i18nc("length unit symbol", "mi"),
286 i18nc("unit description in lists", "miles"),
287 i18nc("unit synonyms for matching user input", "mile;miles;mi"),
288 symbolString,
289 ki18nc("amount in units (real)", "%1 miles"),
290 ki18ncp("amount in units (integer)", "%1 mile", "%1 miles")));
291
292 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
293 id: NauticalMile,
294 multiplier: 1852,
295 i18nc("length unit symbol", "nmi"),
296 i18nc("unit description in lists", "nautical miles"),
297 i18nc("unit synonyms for matching user input", "nautical mile;nautical miles;nmi"),
298 symbolString,
299 ki18nc("amount in units (real)", "%1 nautical miles"),
300 ki18ncp("amount in units (integer)", "%1 nautical mile", "%1 nautical miles")));
301
302 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
303 id: LightYear,
304 multiplier: 9.46073e+15,
305 i18nc("length unit symbol", "ly"),
306 i18nc("unit description in lists", "light-years"),
307 i18nc("unit synonyms for matching user input", "light-year;light-years;ly;lightyear;lightyears"),
308 symbolString,
309 ki18nc("amount in units (real)", "%1 light-years"),
310 ki18ncp("amount in units (integer)", "%1 light-year", "%1 light-years")));
311
312 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
313 id: Parsec,
314 multiplier: 3.08568e+16,
315 i18nc("length unit symbol", "pc"),
316 i18nc("unit description in lists", "parsecs"),
317 i18nc("unit synonyms for matching user input", "parsec;parsecs;pc"),
318 symbolString,
319 ki18nc("amount in units (real)", "%1 parsecs"),
320 ki18ncp("amount in units (integer)", "%1 parsec", "%1 parsecs")));
321
322 d->addUnit(unit: UnitPrivate::makeUnit(categoryId: LengthCategory,
323 id: AstronomicalUnit,
324 multiplier: 1.49598e+11,
325 i18nc("length unit symbol", "au"),
326 i18nc("unit description in lists", "astronomical units"),
327 i18nc("unit synonyms for matching user input", "astronomical unit;astronomical units;au"),
328 symbolString,
329 ki18nc("amount in units (real)", "%1 astronomical units"),
330 ki18ncp("amount in units (integer)", "%1 astronomical unit", "%1 astronomical units")));
331
332 return c;
333}
334
335} // KUnitConversion namespace
336

source code of kunitconversion/src/length.cpp