Bruker:Johnuniq/translate
I have uploaded the following:
- Template:Konverter/sandbox • Template that invokes the module.
- Module:Convert • Module doing the work for unit conversion. Do not edit
- Module:Convert/text • Output text and input parameters. Needs editing!
- Module:Convert/data • Definitions of units. Do not edit
I have done a rough translation of some names using the template here as a guide. See the history of the above for the changes.
I am trying to keep the main convert module the same on each wiki. There may be a couple of small changes that are needed for here, but I if that is so I will try to work out a generic way to do it so the module can be the same everywhere.
The convert/data module is generated by a script from a master table that I have. Later, I will upload that, and the convert data can then be changed. Johnuniq (diskusjon) 17. feb. 2014 kl. 12:42 (CET)
Done
[rediger | rediger kilde]- I can easily configure the module so it uses "," as the decimal mark instead of ".".
- The module can display gaps for long numbers, but that has not been used yet, and I haven't got around to thinking about how to set it up.
- I will need advice on how plurals are formed. Why is "miles" being shown? Is that right?
- Lots of things can be translated. I will need to add some information here about that.
Johnuniq (diskusjon) 17. feb. 2014 kl. 12:32 (CET)
- I have searched trough the units used here at no:wp, and created a table with those units where plural forms differ from single forms:
Unit | single | plural |
---|---|---|
Nautical mile Square nautical mile |
nautisk mil kvadratnautisk mil |
nautiske mil kvadratnautiske mil |
Astronomical unit | astronomisk enhet | astronomiske enheter |
Yard Square yard |
yard kvadratyard |
yards kvadratyards |
Mile Square mile Mile per second Mile per hour |
mile kvadratmile mile per sekund mile per time |
miles kvadratmiles miles per sekund miles per time |
Inch Square inch Cubic inch |
tomme kvadrattomme kubikktomme |
tommer kvadrattommer kubikktommer |
Calorie Kilocalorie Megacalorie Millicalorie |
kalori kilokalori megakalori millikalori |
kalorier kilokalorier megakalorier millikalorier |
Hour Gigawatt hour Kilowatt hour Megawatt hour Watt hour Terrawatt hour |
time gigawatt time kilowatt time megawatt time watt time terrawatt time |
timer gigawatt timer kilowatt timer megawatt timer watt timer terrawatt timer |
Day | dag | dager |
Minute | minutt | minutter |
Second | sekund | sekunder |
Metric ton | metrisk tonn | metriske tonn |
Ounce | unse | unser |
Standard atmosphere | standard atmosfære | standard atmosfærer |
Cocu (d) 18. feb. 2014 kl. 08:45 (CET) PS: Be aware of typos
- I have updated the data with the above information. There was one problem with the fact that second has a plural name because that unit was defined as taking SI prefixes (like ks = kilosecond). The code which automatically accepts units such as ks and Ms does not have access to the plural name of the base unit. That was a shortcut for simplification. This is the first occasion where that is a problem and I'll think about it later. Meanwhile I have removed the SI prefix from the definition for second. That means ks and Ms and so on will not be available unless they are individually defined. I am pretty sure they are not used here so we won't have to worry about that until later. In due course I will make some tests showing the results of the conversions so far. Johnuniq (diskusjon) 19. feb. 2014 kl. 04:24 (CET)
Convert/text
[rediger | rediger kilde]Convert/text needs lots of translations, but not everything is needed because there will be many features that are not used here. I have made a couple of changes already.
To start, please consider what names to use for the error tracking categories:
- Category:Convert invalid units
- Category:Convert invalid options
Actually, I'm starting to think that only one error category is needed. If that appeals, the same name can be used for each of the above. My reasoning is that while lots of problems were recorded in the error categories at en.wiki when the module was first used, after a few weeks they were all fixed and now the categories are usually empty.
See "per_word = 'per'": the text on the right hand side (per) should be fixed for units like "miles per gallon".
The SI prefixes ("kilo" and so on) should be fixed. Search the page for "SIprefixes" to see the list. I need to know the symbol ("k") and the name ("kilo") that is wanted here, or just edit the module.
Bear in mind that in the future, wikitext may be copied from en.wiki to here, so the English converts should probably be kept. For example, do not remove the range word "to", as in "1 to 2 meters". Instead, I have added "til" as an alias for "to", and changed the output to show "til".
What should happen if "|adj=on" is used? At en.wiki that is "adjectival" which changes something like ("a 120 meters bridge" to "a 120-meter bridge"): inserts a hyphen and uses singular unit name. Johnuniq (diskusjon) 18. feb. 2014 kl. 03:15 (CET)
- 1. If two categories, i suggest:
- Kategori:Sider med konverteringsmaler som inneholder enhetsfeil
- Kategori:Sider med konverteringsmaler som inneholder parameterfeil
- If one category, i suggest:
- These categories shoud be put in Kategori:Wikipedia-vedlikehold, and Kategori:Konverteringsmalen.
- Cocu (d) 18. feb. 2014 kl. 08:45 (CET)
- 2. The per_word should be per in norwegian also, example meter per sekund
- Cocu (d) 18. feb. 2014 kl. 11:03 (CET)
- 3. The SI prefixes is shown in the tabel below:
10n Prefix Symbol Name Decimal 1024 yotta Y Kvadrillion 1 000 000 000 000 000 000 000 000 1021 zetta Z Trilliard 1 000 000 000 000 000 000 000 1018 exa E Trillion 1 000 000 000 000 000 000 1015 peta P Billiard 1 000 000 000 000 000 1012 tera T Billion 1 000 000 000 000 109 giga G Milliard 1 000 000 000 106 mega M Million 1 000 000 103 kilo k Tusen 1 000 102 hekto h Hundre 100 101 deka da Ti 10 10−1 desi d Tidel 0,1 10−2 centi c Hundredel 0,01 10−3 milli m Tusendel 0,001 10−6 mikro μ Milliondel 0,000 001 10−9 nano n Milliarddel 0,000 000 001 10−12 piko p Billiondel 0,000 000 000 001 10−15 femto f Billiarddel 0,000 000 000 000 001 10−18 atto a Trilliondel 0,000 000 000 000 000 001 10−21 zepto z Trilliarddel 0,000 000 000 000 000 000 001 10−24 yokto y Kvadrilliondel 0,000 000 000 000 000 000 000 001
Comparison
[rediger | rediger kilde]Wikitext | {{konverter}} | {{konverter/sandbox}} |
---|---|---|
{{konverter|3.21|kg|lb}} |
3,21 kilogram (7,1 lb) | 3,21 kilogram (7,1 lb) |
{{konverter|3.21|kg|lb|0}} |
3,21 kilogram (7 lb) | 3,21 kilogram (7 lb) |
{{konverter|10|kg|lb|disp=eller}} |
10 kilogram eller 22 lb | 10 kilogram eller 22 lb |
{{konverter|6|ft|5|in|m}} |
6 fot 5 tommer (1,96 m) | 6 fot 5 tommer (1,96 m) |
{{konverter|10|mi}} |
10 miles (16 km) | 10 miles (16 km) |
{{konverter|120|km/t}} |
120 kilometer per time (33 m/s) | 120 kilometer per time (33 m/s) |
{{konverter|18|°C|°F}} |
18 °C (64 °F) | 18 °C (64 °F) |
{{konverter|1250|sqft|m2|lk=in|sigfig=2}} |
1 250 kvadratfot (120 m²) | 1 250 kvadratfot (120 m²) |
{{konverter|20.5|m3|cm3|lk=out|abbr=on}} |
20,5 m³ (20 500 000 cm³) | 20,5 m³ (20 500 000 cm³) |
{{konverter|641|acre|ha m2|lk=on}} |
641 acre (259 ha; 2 590 000 m²) | 641 acre (259 ha; 2 590 000 m²) |
{{konverter|641|acre|ha m2|2|lk=on}} |
641 acre (259,40 ha; 2 594 034,97 m²) | 641 acre (259,40 ha; 2 594 034,97 m²) |
{{konverter|60|og|170|kg|lb}} |
60 og 170 kilogram (130 og 370 lb) | 60 og 170 kilogram (130 og 370 lb) |
{{konverter|60|til|170|kg|lb}} |
60 til 170 kilogram (130 til 370 lb) | 60 til 170 kilogram (130 til 370 lb) |
{{konverter|60|til(-)|170|kg|lb}} |
60 til 170 kilogram (130–370 lb) | 60 til 170 kilogram (130–370 lb) |
{{konverter|60|-|170|kg|lb}} |
60–170 kilogram (130–370 lb) | 60–170 kilogram (130–370 lb) |
{{konverter|41|til|50|F|C}} |
41 til 50 °F (5 til 10 °C) | 41 til 50 °F (5 til 10 °C) |
{{konverter|41|-|50|F|K}} |
41–50 °F (278–283 K) | 41–50 °F (278–283 K) |
{{konverter|60|x|120|m|ft}} |
60 ganger 120 meter (200 × 390 ft) | 60 ganger 120 meter (200 × 390 ft) |
{{konverter|60|+/-|10|m|ft}} |
60 ± 10 meter (197 ± 33 ft) | 60 ± 10 meter (197 ± 33 ft) |
{{konverter|19|til|27|l|USgal}} |
19 til 27 liter (5,0 til 7,1 US gal) | 19 til 27 liter (5,0 til 7,1 US gal) |
{{konverter|5|til|7|l|USgal}} |
5 til 7 liter (1,3 til 1,8 US gal) | 5 til 7 liter (1,3 til 1,8 US gal) |
{{konverter|4|-|9|l|USgal|abbr=off}} |
4–9 liter (1,1–2,4 amerikanske gallon) | 4–9 liter (1,1–2,4 amerikanske gallon) |
{{konverter|2|x|4|x|6|m|ft}} |
2×4×6 meter (6,6×13×20 ft) | 2 ganger 4 ganger 6 meter (6,6 × 13,1 × 19,7 ft) |
{{konverter|60|-|70|-|80|kg|lb}} |
60–70–80 kilogram (130–150–180 lb) | 60–70–80 kilogram (130–150–180 lb) |
{{konverter|60|-|70|-|80|-|90|kg|lb}} |
60–70–80–90 kilogram (130–150–180–200 lb) | 60–70–80–90 kilogram (130–150–180–200 lb) |
{{konverter|41|til|50|til|60|F|C}} |
41 til 50 til 60 °F (5 til 10 til 16 °C) | 41 til 50 til 60 °F (5 til 10 til 16 °C) |
{{konverter/X} where X = 2 or 3 or 4 (as well as some other things)
- These are part of the old system and are not needed when the module is used.
- Exception: {{konverter/X}} accepts arbitrary text (like {{konverter/3|2| to almost |4| or sometimes |6|m|ft}}).
- Arbitrary text is not supported by the module.
- See en:Help:Convert#Ranges for the range words supported by the module.
- The output from {{konverter/X}} is not consistent with {{konverter}} (for example, "x" gives slightly different output).
- The following shows that the module uses "*" for an unspaced multiply symbol:
{{konverter/3|2|x|4|x|6|m|ft}}
→ 2×4×6 meter (6,6×13×20 ft){{konverter/sandbox|2|*|4|*|6|m|ft}}
→ 2×4×6 meter (6,6×13,1×19,7 ft)
- Johnuniq (diskusjon) 19. feb. 2014 kl. 10:08 (CET)
Number grouping
[rediger | rediger kilde]I need to know how numbers should be grouped. I gather that digits are grouped in threes, and are separated with a space. That applies to digits before the decimal mark (,
) and after.
The module has the ability to do something more clever than the above, but it only groups digits before the decimal mark. The |comma=gaps
option inserts a "gap" between groups of digits using span tricks such that the number will not wrap, and the number can be copied without spaces. Following are examples. The |comma=gaps5
option only inserts gaps if there are five or more digits.
{{konverter/sandbox|1234567890|m|m|abbr=on}}
→ 1 234 567 890 m (1,23456789×109 m){{konverter/sandbox|1234567890|m|m|abbr=on|comma=gaps}}
→ 1234567890 m (1,23456789×109 m){{konverter/sandbox|1234|m|abbr=on|comma=gaps}}
→ 1234 m (4049 ft){{konverter/sandbox|1234|m|abbr=on|comma=gaps5}}
→ 1234 m (4049 ft){{konverter/sandbox|12345|m|abbr=on|comma=gaps5}}
→ 12345 m (40502 ft)
The above is not working, presumably because of how I configured numsep in the template. I'll have to think about that.Please see what should be happening at en:User:Johnuniq/sandbox (permalink).
If you copy the output, and paste into a local file, you will see that the numbers have no spaces. One drawback with this technique is that it produces quite a lot of html, although that is probably inconsequential. The following shows the html which generates "1234567890":
<span style="white-space: nowrap">1<span style="margin-left: 0.25em">234</span><span style="margin-left: 0.25em">567</span><span style="margin-left: 0.25em">890</span></span>
This is the first wiki where gaps are required, and there is currently no method to configure the module so that always happens. I'll have to do something to format output numbers as wanted, but that will need to wait until I have some time, and I need to know exactly what is wanted.
The module could be modified so it groups numbers using one of the following. Which is wanted?
- Spaces (which is what happens now).
- Nonbreaking spaces (
). - Gaps (using the
<span>
trick above).
Should "1234" have a space/gap?
I will have to modify the module so that it groups digits after the decimal mark (do you want that?). Should "0.1234" have a space/gap? Johnuniq (diskusjon) 19. feb. 2014 kl. 10:08 (CET)
- The thousand separator in norwegian is a nonbreaking space. After the decimal mark, there should be no spaces. The result should be equal to the result when using formatnum:
- {{Formatnum:1234}} → 1 234
- {{Formatnum:1234.1234}} → 1 234,1234
- {{Formatnum:12341234}} → 12 341 234
- Cocu (d) 21. feb. 2014 kl. 15:12 (CET)
- OK, I have implemented that. Use Special:ExpandTemplates to see that " " occurs in the output. Johnuniq (diskusjon) 22. feb. 2014 kl. 10:46 (CET)
Questions
[rediger | rediger kilde]Q1 What should happen if "|adj=on" is used? At en.wiki that is "adjectival" which changes something like "a 120 meters bridge" to "a 120-meter bridge". It inserts a hyphen and uses the singular unit name. Johnuniq (diskusjon) 22. feb. 2014 kl. 10:46 (CET)
- It should use plural form, and insert an s at the end, exept for those units which already contains an s at the end, like miles and yards. For example «en 2 kilos fisk», and «3 tommers bredde». Cocu (d) 24. feb. 2014 kl. 07:19 (CET)
- @Cocu: This a problem! Do you mean «3 tommers bredde» or «3 tommer bredde»? The current definition for unit code "in" is that the singular name is "tomme" and the plural name is "tommer" (no "s"). Examples:
{{konverter/sandbox|1|in|mm}}
→ 1 tomme (25 mm){{konverter/sandbox|3|in|mm}}
→ 3 tommer (76 mm)
- Also, unit code "kg" is defined as "kilogram" for both singular and plural:
{{konverter/sandbox|1|kg|lb}}
→ 1 kilogram (2,2 lb){{konverter/sandbox|3|kg|lb}}
→ 3 kilogram (6,6 lb)
- Are the above converts correct? If not, I need some examples of what the output text should be, and a rule for what name should occur when. Johnuniq (diskusjon) 25. feb. 2014 kl. 02:24 (CET)
- I was probably a bit imprecise, I see now. There will be a s at the end both singular and plural form, except for those who already have an s at the end - such as the plural forms yards and miles. The singular forms of yard and mile get an s at the end. For example, «1 tommes bredde» and «2 tommers brede, «1 times løpetur» and «2 timers løpetur». For those units with similar singular and plural form, the adjectival form will ble similar also, for example «1 kilos fisk» and «2 kilos fisk», «1 meters lengde» and «2 meters lengde». However, if it is problematic to achieve this, we can get by fine without the «|adj=on» option. I hope this was clarifying. Cocu (d) 1. mar. 2014 kl. 21:06 (CET)
- @Cocu: This a problem! Do you mean «3 tommers bredde» or «3 tommer bredde»? The current definition for unit code "in" is that the singular name is "tomme" and the plural name is "tommer" (no "s"). Examples:
Q2 Two pages are needed for the table which defines the units, and I need to know what titles to use. At en.wiki, the pages are:
- en:Module:Convert/documentation/conversion data/doc – master list of unit definitions
- en:Module:Convert/documentation/conversion data introduction/doc – explanations transcluded into above
You can have whatever titles are wanted, but for consistency across wikis it might be simplest to use the English titles, but change the "doc" to "dok" per standard here. What is wanted? Johnuniq (diskusjon) 22. feb. 2014 kl. 10:46 (CET)
- Using the English titles is OK. Cocu (d) 24. feb. 2014 kl. 07:19 (CET)
- I realized that the second of the above pages is not needed, so I have only created an equivalent of the first, as shown at #Conversion data below. Johnuniq (diskusjon) 3. mar. 2014 kl. 04:41 (CET)
Q1 result Please check the following results. Is this what is wanted?
{{konverter/sandbox|1|in|mm}}
→ 1 tomme (25 mm){{konverter/sandbox|2|in|mm}}
→ 2 tommer (51 mm){{konverter/sandbox|1|in|mm|adj=on}}
→ 1 tommes (25 mm){{konverter/sandbox|2|in|mm|adj=on}}
→ 2 tommers (51 mm){{konverter/sandbox|1|in|mm|adj=mid|bredde}}
→ 1 tommes bredde (25 mm){{konverter/sandbox|2|in|mm|adj=mid|bredde}}
→ 2 tommers bredde (51 mm){{konverter/sandbox|1|mi|km|adj=mid|bredde}}
→ 1 miles bredde (1,6 km){{konverter/sandbox|2|mi|km|adj=mid|bredde}}
→ 2 miles bredde (3,2 km){{konverter/sandbox|1|h|min|adj=mid|løpetur}}
→ 1 times løpetur (60 min){{konverter/sandbox|2|h|min|adj=mid|løpetur}}
→ 2 timers løpetur (120 min){{konverter/sandbox|1|kg|lb|adj=mid|fisk}}
→ 1 kilograms fisk (2,2 lb){{konverter/sandbox|2|kg|lb|adj=mid|fisk}}
→ 2 kilograms fisk (4,4 lb){{konverter/sandbox|1|m|ft|adj=mid|lengde}}
→ 1 meters lengde (3,3 ft){{konverter/sandbox|2|m|ft|adj=mid|lengde}}
→ 2 meters lengde (6,6 ft)
- The "kg" examples output "kilogram" (or "kg" if
|abbr=on
is used). Something different can easily be handled, but I would need examples of wanted output. Please check the results on this page, and perhaps try a few tests in a sandbox. If everything is ok, I will create the pages with the unit definitions. Johnuniq (diskusjon) 2. mar. 2014 kl. 06:32 (CET)
By the way, I noticed the following at Rødlønn#Beskrivelse. The current template is showing "3 5 til 4 3" but it should be "3,5 til 4,3".
{{konverter|9|to|11|cm|in}}
→ 9 til 11 centimeter (3,5 til 4,3 "){{konverter/sandbox|9|to|11|cm|in}}
→ 9 til 11 centimeter (3,5 til 4,3 ")
Some other differences are as follows.
{{konverter|0.0312|AE|km|abbr=on|lk=on}}
→ 0,0312 AE (4 670 000 km){{konverter/sandbox|0.0312|AE|km|abbr=on|lk=on}}
→ 0,0312 AE (4 670 000 km){{konverter|12400|m/s|abbr=on|sigfig=4}}
→ 12 400 m/s (44 640 km/t){{konverter/sandbox|12400|m/s|abbr=on|sigfig=4}}
→ 12 400 m/s (44 640 km/t)
If there are any problems with results from konverter/sandbox, please say what should occur. Johnuniq (diskusjon) 2. mar. 2014 kl. 09:23 (CET)
- In the first two examples, the sandbox template gives the correct result. In the last one, however, the current template gives the correct result. The unit m/s should convert to km/t, unless otherwise specified. Cocu (d) 2. mar. 2014 kl. 16:07 (CET)
Conversion data
[rediger | rediger kilde]I have uploaded the conversion data. The procedure to fix unit definitions is as follows.
- Edit Modul:Convert/documentation/conversion data/dok to make any required updates.
- At Moduldiskusjon:Convert/makeunits, click "purge this page" in the first line.
- Copy all text in the box.
- Edit Modul:Convert/data, select all text in the module, then paste to replace with the above copy.
- Perhaps click "Show changes" at the bottom to confirm what you are changing.
- Save.
The updates should be immediately available, but you may need to purge a page using the convert template to see the changes. Johnuniq (diskusjon) 3. mar. 2014 kl. 04:39 (CET)
To do
[rediger | rediger kilde]I see that the module is now live, so I checked Kategori:Sider med konverteringsmaler som inneholder feil, and it shows one error at 243 Ida. More may show up in a few days because the system can be slow to rollout changes. The Omløpstid convert at Mal:Planetinfo/243 Ida could be changed to use output unit "year" which would show "a" as the abbreviated symbol. That symbol could be changed to "år". Or, the units could be edited to add an alias with a new row in the Time section showing "år =year" (and change the symbol and name of the year unit).
Whenever wanted, a lot more translations can be performed, mainly at Modul:Convert/text, starting with "all_messages". Currently an error shows en text, and some reasonably straightforward translations would fix that. Examples:
{{konverter|1200|m|ha}}
→ 1 200 meter ([konverter: enhetskrasj]){{konverter|1200|m|whatever}}
→ 1 200 meter ([konverter: ukjent enhet])
There are two ways to make the red link go away. Simplest is to edit the messages to link to en:Help:Convert messages. An alternative would be to copy that page to here and eventually translate it. Johnuniq (diskusjon) 7. mar. 2014 kl. 08:03 (CET)
SI units
[rediger | rediger kilde]I have made some major changes to the modules and updated unit s
(second) to accept SI prefixes. That probably won't have any effect here because not many articles need things like megaseconds, however it is better for the updates to be installed to simplify any changes required in the future. Previously, Modul:Convert/makeunits enforced certain assumptions for simplicity at en.wiki. However, it is now possible for an SI prefix to be inserted at different positions in the singular and plural names for an SI unit. Also, the singular and plural US spelling of the names can be different and can have the SI prefix inserted at different positions. The only restriction is that the SI prefix is always inserted in front of the symbol (that is, when abbr=on applies). Please let me know if testing shows any problems. Johnuniq (diskusjon) 28. mar. 2014 kl. 03:35 (CET)
Wikidata
[rediger | rediger kilde]Hi, thank you for your good job with this template. Could you please help fixing this template so that it is possible to retrieve from Wikidata? I have tried but don't understand why its not working. Tholme (diskusjon) 23. okt. 2019 kl. 20:05 (CEST)
- Hi, @Johnuniq:. Not sure if you got notified about this, so I tried to ping you. Please feel free to ignore this if you already got the message. Tholme (diskusjon) 7. mar. 2020 kl. 01:04 (CET)
- @Tholme: Is there an example of what you want to do and what outcome was wanted? What did you try? Johnuniq (diskusjon) 7. mar. 2020 kl. 02:28 (CET)
- @Johnuniq: Yes, ofcourse. See for example Template:Infoboks teleskop. When trying to get data from wikidata I only get the error message Feil ved konvertering: Verdien "X" må være et tall (Error converting: Value "X" must be a number)
- @Tholme: Is there an example of what you want to do and what outcome was wanted? What did you try? Johnuniq (diskusjon) 7. mar. 2020 kl. 02:28 (CET)
Heres some examples:
{{convert|qid=Q10428388|input=P2046|qual=Q15063765|sqkm|abbr=on|disp=out|1}}
→ 464,7 km². (Error converting: Value "kg" must be a number) I would expect this to give value for P2046 with qualifier Q15063765 and with precision 1 (464.7 km2)
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ 10,0 m (32,8 ft){{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ 1 m (3,3 ft)
Tholme (diskusjon) 8. mar. 2020 kl. 00:10 (CET)
- @Tholme: I merged some changes at enwiki into Module:Convert/text. I imagine that has not been updated due to the difficulty of working out what is wanted. There may be problems from the changes depending on exactly what converts are used here. Please check the error category over the next few days and let me know if you need help. I did not merge all the enwiki changes because considering the effect of some of them would take too much time (the changes happened years ago and I've forgotten the details). The problem was that parameters like
input
were being ignored because they were not defined in the text module. Johnuniq (diskusjon) 8. mar. 2020 kl. 02:16 (CET)