KUnitConversion

length.cpp
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(LengthCategory, i18n("Length"), i18n("Length"));
19 auto d = UnitCategoryPrivate::get(c);
20 KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (length", "%1 %2");
21
22 d->addUnit(UnitPrivate::makeUnit(LengthCategory,
23 Yottameter,
24 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(UnitPrivate::makeUnit(LengthCategory,
33 Zettameter,
34 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(UnitPrivate::makeUnit(LengthCategory,
43 Exameter,
44 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(UnitPrivate::makeUnit(LengthCategory,
53 Petameter,
54 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(UnitPrivate::makeUnit(LengthCategory,
63 Terameter,
64 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(UnitPrivate::makeUnit(LengthCategory,
73 Gigameter,
74 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(UnitPrivate::makeUnit(LengthCategory,
83 Megameter,
84 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(UnitPrivate::makeUnit(LengthCategory,
93 Kilometer,
94 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(UnitPrivate::makeUnit(LengthCategory,
103 Hectometer,
104 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(UnitPrivate::makeUnit(LengthCategory,
113 Decameter,
114 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(UnitPrivate::makeUnit(LengthCategory,
123 Meter,
124 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(UnitPrivate::makeUnit(LengthCategory,
133 Decimeter,
134 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(UnitPrivate::makeUnit(LengthCategory,
143 Centimeter,
144 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(UnitPrivate::makeUnit(LengthCategory,
153 Millimeter,
154 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(UnitPrivate::makeUnit(LengthCategory,
163 Micrometer,
164 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(UnitPrivate::makeUnit(LengthCategory,
173 Nanometer,
174 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(UnitPrivate::makeUnit(LengthCategory,
183 Angstrom,
184 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(UnitPrivate::makeUnit(LengthCategory,
193 Picometer,
194 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(UnitPrivate::makeUnit(LengthCategory,
203 Femtometer,
204 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(UnitPrivate::makeUnit(LengthCategory,
213 Attometer,
214 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(UnitPrivate::makeUnit(LengthCategory,
223 Zeptometer,
224 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(UnitPrivate::makeUnit(LengthCategory,
233 Yoctometer,
234 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(UnitPrivate::makeUnit(LengthCategory,
243 Inch,
244 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(UnitPrivate::makeUnit(LengthCategory,
253 Thou,
254 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(UnitPrivate::makeUnit(LengthCategory,
263 Foot,
264 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(UnitPrivate::makeUnit(LengthCategory,
273 Yard,
274 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(UnitPrivate::makeUnit(LengthCategory,
283 Mile,
284 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(UnitPrivate::makeUnit(LengthCategory,
293 NauticalMile,
294 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(UnitPrivate::makeUnit(LengthCategory,
303 LightYear,
304 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(UnitPrivate::makeUnit(LengthCategory,
313 Parsec,
314 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(UnitPrivate::makeUnit(LengthCategory,
323 AstronomicalUnit,
324 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
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 Fri Nov 22 2024 12:10:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.