The list of Val units is published at قالب:Val/list, and here is the place that produces that report. So preview {{Val/list}} from the edit box to see your changes before saving them. The file format and syntax are mostly self explanatory.

  • The field separator is two or more spaces.
  • You can enter new units in the "Unsorted units" section if you are not sure where else it might go.
  • If the same unit code is defined twice on this page, the first one overrides the later one.
  • For new entries the style guideline is Wikipedia:UNITS.
  • Convert and Val share units. If you have an issue with a unit pagename or a unit symbol, and that unit is not published at Val/list, you may decide to address it at Template talk:Convert. To override entries at Convert, make an entry here.
  • If you're not in a hurry, you may notice when editing Val/units that it consists of two Lua string assignments, and Lua comments. Be careful.

Questions or requests related to Val units are welcomed at Template talk:Val. For feedback specifically about the terminology or procedural steps seen on this page, please use the talk page.

Below are the detailed procedures, examples, descriptions of testing and previewing, explanations about sorting Val expressions, and links to helpful pages. There's also further information about Val/Convert relations.

Introduction

تعديل

An entry defining a unit for Val is a single line under a section heading.[1] It starts with the unit code, followed by at least two spaces and a link. If you are adding a group of related units, you can enter a blank line around them to group them in the report at Val/list. An entry is ignored if it lacks at least two adjacent space characters.

code    [[ pagename | symbol ]]
unit code
The keyboard typeable name of the symbol that users give Val's |u=, |ul=, |up= or |upl= parameters.
  • Unit codes will be case sensitive.
  • Prefer u for the Greek letter μ, if you're not sure.
  • Composite units have dimensions that multiply, divide, and apply powers to component units. Use . to multiply, / to divide, and a signed digit for powers. For multiplication, * is deprecated. When adding a unit that includes division, consider also adding a version with multiplication by the negated power; for example, m/s2 and m.s-2 (for m/s2 and m⋅s−2).
unit pagename
Title or section of an article. When linked with ul or upl, the title or one of its redirects can expand the abbreviation for the unit.[2]
unit symbol
Verifiable, standard symbol, formatted in accordance with WP:UNITS.
  • Templates will not work for producing the unit symbol for input to this module; only Wikipedia HTML formatting is accepted.
  • Composite units use &sdot; to multiply, / to divide, and <sup></sup> for powers. Division is also the unit-inversion form that multiplies a negative numbered power, for example for m/s2 and m⋅s−2 (from m.s-2 and m/s2).
  • If the hover-text just shows the abbreviation, it is not a user-friendly unit-symbol. When not linked, the unit's abbreviation can be spelled out with hover-text at the symbol by way of the title attribute of either <abbr></abbr> or <span></span>.
  • For more about HTML tags and HTML symbols such as &sdot;, see Wikipedia:HTML.
  • For more information about marking up your unit symbol see WP:HTML#formatting.
  • Examples of unit codes, and hover text are at قالب:Val/list.
unit code alias
The same unit/pagename/symbol, but by way of a different unit code.
Unit code aliases are commonly applied for
  • capitalization, to make the unit code case insensitive.
  • per units, for example m/s and m⋅s−1.
  • Greek letters, to allow for both US keyboard and Greek-character-input applications, for example the SI prefix μ
Preview page with this template/module
A feature, similar to a sandbox and testcases, that provides a preview of how the code currently in the edit box (sandbox) will look when applied to any page (testcases).

The preview of main interest is Template:Val/list,[3] but previewing other your own page of interest with your newly added unit in a val call and in a sorting table are also part of this procedure. قالب:Val/units/testcases contains Val calls for all defined Val units.

How to add a unit

تعديل

To maintain Val units,

  1. Edit Module:Val/units and make your changes.
  2. Preview   Template:Val/list   .
    • Look for any messages. An "Invalid definition" message is available automatically.
    • Prove the intended link from the preview.
    • Hover the mouse over the link, and read the hover-text or URL display somewhere in the browser.
  3. Add any unit-code aliases.
  4. Add any sorting if needed. Details about sorting are covered below.
  5. Preview a test page. It will have template Val calls on it, and it may have a sortable table to test sorting. قالب:Val/units/testcases is a test page containing Val calls for all units.
  6. Show changes to prove no accidental edits occurred.
  7. Save the page. Saving the page activates the changes immediately, and they go live. You're done adding your unit.

If you want a unit to add for practice, add one from List of common physics notations, or from SI units#Units and prefixes.

Changing or removing existing unit codes is possible by employing {{Template usage}} to see how Val unit codes may or may not be in use on the wiki. For example, to see about changing or removing unit code J.s, do a

{{tlusage|val|"J.s"|0}}قالب:Tlusage.

Put any unit code in quotes if it contains dash, dot, or slash—anything but a letter or number. See قالب:Val/units/test for a list of these searches for each Val unit.

Examples

تعديل

Say you're creating a new page or revamping an old page, and discover the need for a convenient way to make several entries containing c0, and link that symbol to the page Speed of light. The following entry will define your unit code as c0, your unit symbol as ''c''<sub>0</sub>, and the unit's article as Speed of light#Numerical value, notation, and units.

c0  m&sdot;s<sup>&minus;1</sup>]] linking to an article titled Metre per second, not

m.s-1  [[Metre is going to Celsius instead of Coulombs, you can define your own unit code, say "degC".

The following defines degC to refer to the unit known as °C in convert. There is no link because a link is defined at Convert.

degC               °C               ALIAS

File format

تعديل

If you want to reorganize sections here, note that the two lines local builtin_units and local builtin_units_long_scale require a blank line after them. The section long scale, with all the units like "billions" and "trillions", is under the latter, near the bottom of the page. All the rest of the units are in the former.

The file format is two Lua strings and a return statement with them in it: a string in quotes [=[ ... builtin_units ... ]=], and another string in quotes [=[ ... builtin_units_long_scale ... ]=]. The first string, builtin_units, is short-scale, second string is long scale. The reason there are two strings is because of the difference between British and US terms surrounding "billion", "billionth", etc.

For each string there must be a blank line before the first line of the string and after the last line of the string. In other words the first two and last two characters of each string must be newlines.

There is one record per line, starting in first column, having 2-4 fields. The field separator is two or more spaces. Between first and second fields, use two or more spaces. Between all other fields, use two or more spaces, or one or more tabs. Entries without two spaces in them are ignored.

Advanced unit flags

تعديل

You can alias Convert or Val units. But these are different things.

  • A "unit code alias" is when the same unit pagename and unit symbol are defined twice. If a different unit code is assigned to the same unit symbol and unit pagename, (say, as a copy of the previous entry) it will work as a Val alias.
  • A "unit alias" is when Val alias a Convert unit code. A unit of measurement is here denoted ALIAS to mean "they are defined there". Val defaults to Convert, but it's good to this explicit for certain Val units: the ones tempting to define here, but that you don't want defined here because, says ALIAS, they are already defined there.
  • If your unit code is not listed at {{Val/list}}, you can check for it at {{Val/unitsfromconvert}}, or at {{Convert#Units}}

For spacing and aliasing:

  • ALIAS specifies that the unit's symbol is the code for a unit defined in {{convert}}}.
  • NOSPACE prevents the default insertion of a non-breaking space before the unit symbol.
  • If you see the ANGLE flag, this identifies those special units that must displayed not only after the main Val number, but also after its uncertainty#Measurements numbers.(ANGLE also implies NOSPACE.)

Interaction with Convert

تعديل

Val and Convert share unit codes, but their units of measurement are different.

  • Most of the wiki's unit codes are managed by {{Convert}}.
  • Some very few unit codes here, like C and F, mean something different there. Val caters to Coulombs and Farads, while Convert caters to Celsius and Fahrenheit. Convert and Val unit codes are mostly identical, like they are for degC and for degF.
  • Val could need any unit, while not all units are needed in conversions, so Val needs all of Convert's units and some of its own.
  • Sorting functionality is handled for Val by {{convert}}.)
  • At Convert the procedure for defining a unit is much more involved than it is here, because there every unit defined must reference associated units, conversion factors, alternate spellings, and many other attributes. An entry at Convert is defined as a multi-line, multi-attribute Lua table with its attendant syntax, and inside a larger Lua script. Therefore Convert is more conservative about adding units. Val may be more liberal in this respect if only because unit entry is simpler and "wikified". Therefore WP:Be bold. Bold customization may be a worthwhile risk at Val/units, or it may get removed. Although units used in articles have definite stylistic standards, there remains room for depending on Val for markup (but see WP:Accessibility about color, link, and text). You may want to customize some Val unit codes that will automate some Val markup for special articles, the talk page, etc. See WP:HTML#formatting for possibilities.
  1. Module pages don't have section editing.
  2. A redirect page is easy to make; there are tools on the editor toolbars.
  3. The special relation between Val/units and Val/list is that the wikitext of Val/list is always generated by Val/units when that page is viewed, so when you preview page with this module, Val/list is generated using the contents of the edit box of Val/units.

See also

تعديل