Module:Citation/CS1/doc/Importing the Module:Citation/CS1 suite to your wiki

From MOASSpedia
< Module:Citation‎ | CS1‎ | doc
Jump to navigation Jump to search

According to Help:Citation Style 1: "Citation Style 1 (CS1) is a collection of reference citation templates that can be modified to create different styles for different referenced materials. Its purpose is to provide a set of default formats for references on Wikipedia. It includes a series of templates that in turn use Module:Citation/CS1."

As an example of a template see {{Cite web}}. The template is written in Lua and it calls Module:Citation/CS1 and a number of (sub)modules.

Basicly to make this work on another wiki you need

  1. To import/copy the 9 (sub)modules etc. listed on Module:Citation/CS1/doc
  2. One or more of the templates listed on Help:Citation_Style_1#Templates
  3. Modify the modules to work on your wiki
  4. Create the relevant categories and help text to assist users to fix errors

This page will try to tell you how to modify the module. Examples from the Danish Wikipedia is used but if/when other wikis also have examples please add them at the relevant place.

Module:Citation/CS1

Module:Citation/CS1 contains rendering and support functions. <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

The module checks if |page= has text like p. pp. etc. before the number. Some variants are accepted and some are not.

  • "Example of a page parameter with valid text". p. P3.
  • "Example of a page parameter with invalid text". p. Pg. 3. {{cite web}}: |page= has extra text (help)

What to modify in ~CS1 on your wiki

If you change the name of the submodules or uses sandboxes you have to change the path/name so the module knows where to look for the submodules. Danish Wikipedia have not changed the names but the Danish word for "Sandbox" is "Sandkasse" so that was updated with da:Special:Diff/11031220.

The module also tells that if some parameters like |volume= is only meant to be shown if |journal= or |work= is used. In Danish Wikipedia the local name for the 2 parameters are |tidsskrift= and |værk=. So those 2 were added with da:Special:Diff/11003206. A few more should be added too.

As mentioned above the module checks if |page= has text and if local wiki wants it can add local variants or remove the English variant.

<other examples?>

Module:Citation/CS1/Configuration

Module:Citation/CS1/Configuration contains translation tables; error and identifier handlers. <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

It has several sections among which are:

  1. translation tables that contain most of the literal strings that may be included in Lua-based citation.
  2. a list of error conditions specifying what text to display, what category to include (if any), and what help page section to refer to when errors are detected
  3. a list of ID handlers specifying the recognized document IDs, such as ISBN, DOI, etc., and how to format them.

What to modify in ~Configuration on your wiki

If editors are copying this Module to another wiki using a language other than English, then they should translate each of the values in the translation tables into that language.

Some translated text is directly visible in the text and other translated text is only relevant to make it possible to use a parameter in a local language.


The first bundle of changes in Danish Wikipedia was related to visible text (or at least that was the intent). So we translated namespaces, various text, month names etc. with these edits da:Special:Diff/11034869 + da:Special:Diff/11035102 and da:Special:Diff/11036193. The plan was to translate all in one diff but a few things was forgotten. Examples

['archived-dead'] = 'Archived from $1 on $2',

Was translated to:

['archived-dead'] = 'Arkiveret fra $1 $2',


['pp-prefix'] = "$1 pp. $2",

Was translated to:

['pp-prefix'] = "$1 s. $2", -- Danish word for page is side and both page and pages is s. in short.


The second bundle on Danish Wikipedia was adding Danish parameter names etc. The changes was made with these edits da:Special:Diff/11034957 + da:Special:Diff/11034999 and da:Special:Diff/11035102. The plan was to translate all in one diff but a few things was forgotten. Examples

['Language'] = {'language', 'lang'},

Was translated to:

['Language'] = {'language', 'in', 'sprog', 'på', 'språk', 'langue', 'lang', 'Language'}, -- notice it contains old parameters from English Wikipedia, Danish variants and even a Swedish variant. Danish Wikipedia allowed other languages etc. to make it easy to copy templates to dawiki. Not sure it is something to recommend to other wikis to so.


The third bundle on Danish Wikipedia was translating error messages and error categories. The changes was made with this edit da:Special:Diff/11035100. Examples

err_apostrophe_markup = {

message = 'Italic or bold markup not allowed in: <code class="cs1-code">|$1=</code>', -- $1 is parameter name
anchor = 'apostrophe_markup',
category = 'CS1 errors: markup',
hidden = false
},

was translated to

err_apostrophe_markup = {

message = 'Kursiv eller fed markup er ikke tilladt i: <code class="cs1-code">|$1=</code>', -- $1 is parameter name -- This is the message shown on the page.
anchor = 'apostrophe_markup',
category = 'CS1-fejl: markup', -- This is the category name the page will be categorized in.
hidden = false
},


The fourth bundle on Danish Wikipedia was to make it possible to have a "." (dot) in translated dates. In Danish the date "1 February 2022" would be "1. februar 2022". The change was made like this da:Special:Diff/11034984 (ignore the changes next to "['yMd']" and the last comment).


The fifth bundle/change on Danish Wikipedia is whether you like to use redirects in identifiers, use local category names and to translate month-names. The changes are turned on with true/false. The changes was done like this da:Special:Diff/11035019.

Below is an example how it will look an |isbn= is added:

Notice that the link on ISBN goes to ISBN (identifier) that is a redirect that leads to International Standard Book Number. English Wikipedia uses that to make it possible to separate pages where ISBN is used in the text with an wikilink and where the mentioning is in a ref.

Module:Citation/CS1/Whitelist

Module:Citation/CS1/Whitelist contains lists of active and deprecated CS1|2 parameters. <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

This module contains a list of all parameters that Module:Citation/CS1 knows about. Each parameter is assigned a state.

  • true: These parameters are valid and supported parameters
  • false: These parameters are deprecated but still supported
  • 'tracked': These parameters are valid and supported parameters tracked in an eponymous properties category.
  • nil: Parameters not present are not supported, or no longer supported.

The basic_arguments table is supported by all templates. The other tables are only used for some templates

What to modify in ~Whitelist on your wiki

If you add new parameters to your local wiki you should also add them to ~Whitelist.

In Danish Wikipedia Danish, Swedish, Norwegian was added with da:Special:Diff/11031399. So far they were added in a block and not sorted alphabetically. So far it has not given any problems.

However the list should be complete and Danish Wikipedia have not yet done a cleanup and made sure that there is a match between ~Configuration and ~Whitelist. That should be done.

At da:Moduldiskussion:Citation/CS1#mismatches_between_whitelist_and_configuration there is a notice on how to clean up such problems. Here are the commands:

=p.aliases – returns the list of parameters and their associated meta parameter from the ~/Configuration module
=p.aliases_dups – returns a list of parameters that appear in more than one meta parameter (not necessarily a bad thing depending on the version of the cs1|2 module suite)
=p.whitelist – returns the list of parameters from the ~/Whitelist module
=p.alias_params_not_in_whitelist – returns a list of parameters found in the ~/Configuration module but not found in the ~/Whitelist module
=p.wh_params_not_in_aliases – returns a list of parameters found in the ~/Whitelist module but not found in the ~/Configuration module

<perhaps there should be a little more information about this hack and what problems it might give>

Module:Citation/CS1/Date validation

Module:Citation/CS1/Date validation contains date format validation functions.

The module understand dates like 1 February 2022 and seasons like spring, easter etc.

The module will try to understand the date and then test if it is a valid date.

Examples

Once a date is checked the module can reformat it if the template has provided the code for that

The module uses identifier letters: 'd' (day), 'm' (month), 'a' (anchor year), 'y' (year); second day, month, year have a '2' suffix. When a month is written with digits it is named 'm' and when the month is written with letters it is named 'M'. Since days and years are always written with digits there is no 'D' or 'Y'.

So

['ymd'] = 2022-02-01
['Mdy'] = February 1, 2022
['Md-Mdy'] = January 20 – February 1, 2022

<Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

What to modify in ~Date validation on your wiki

The first thing to be changes in Danish Wikipedia is that in Danish a "." (dot) is used in dates. So in Danish February 1, 2022 would be written as "1. februar 2022" (with a dot after the day and with a small letter in month name).

There is no pattern for Danish dates so

['d.My'] = 1. februar 2022
and other variants using "d."

etc. have to be created. See da:Special:Diff/11035148 (ignore the comments next to "['yMd']").

The diff above also contain a modification of the way hyphen and (n)dash is used. Danish Wikipedia does it differently than on English Wikipedia. However, the code added on Danish Wikipedi changes the hyphen/dash correctly but it leaves a message that something was changed even when it was not changed. So the code has to be changed.


The second thing to change is that c. is written as ca. and nd (no date) would be u.å. (uden år). Changed with this diff da:Special:Diff/11035153.

Module:Citation/CS1/Identifiers

Module:Citation/CS1/Identifiers contains functions that support the named identifiers (ISBN, DOI, PMID, etc.). <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

The module does a number of check to see if the identifiers are in a valid format.

Below is an example how it will look an |isbn= is incorrect (both during preview and when saved):

What to modify in ~Identifiers on your wiki

No modifications should be needed.

Module:Citation/CS1/Utilities

Module:Citation/CS1/Utilities contains common functions and tables. <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

One of the things the module does is to convert a hyphen ( - or ‐ ) to a dash ( – ) if used in |pages= and |issue=. So instead of pp. 6–7 it makes the template show pp. 6-7.

What to modify in ~Utilities on your wiki

In Danish Wikipedia a hyphen is used instead of a dash. So to make the code work correctly the code have to be reversed.

It was done like this in the Danish sandbox: da:Special:Diff/11031253 (instead of just changing the code the original enwiki code was commented).

No other modifications should be needed.

Module:Citation/CS1/COinS

Module:Citation/CS1/COinS coontains functions that render a CS1|2 template's metadata used for COinS. <Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

What to modify in ~COinS on your wiki

No modifications should be needed.

Module:Citation/CS1/styles.css

Module:Citation/CS1/styles.css contains CSS styles applied to the CS1|2 templates.

<Please add more text. Remember it may be used by by someone that is not an expert in coding and not a native English user. So better to add extra info and help links than to assume reader will know/understand.>

Here you can define how it should look depending on wether websites are free, requires registration etc.

See more help/info on Template:Cite_web/doc#Subscription_or_registration_required. On how it looks.

What to modify in ~styles.css on your wiki

If you are happy with the same format as used on English Wikipedia no changes are needed. Danish Wikipedia have made no changes.

But if you for example want to change the red lock to some bills and coins you can change this line (# 59 when this text was written)

url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)

<Other examples of what to change and how?>

Module:Citation/CS1/Suggestions

Module:Citation/CS1/Suggestions contains lists that maps common erroneous parameter names to valid parameter names.

The lists are in the form ['incorrect'] = 'correct', like this:

['doibroken'] = 'doi-broken-date', -- This is an example of a parameter no longer used

['datum'] = 'date', -- This is an example of a parameter in another language (German)

['langauge'] = 'language', -- This is an example of a misspelling of the parameter

Below is an example how it will look if suggestions is used (both during preview and when saved):

What to modify in ~Suggestions on your wiki

It would be a good idea to add typical misspellings in your language here to make it easy for users to find the right name. If users often copy templates from another wiki to your wiki you could also add the foreign names to the list.

There are no examples from Danish Wikipedia because they have chosen to make parameters in a number of languages valid instead of using suggestions. So instead of adding for example German or Norwegian parameters to ~Suggestions they have been added to ~Whitelist. That makes it easy to copy cite templates from other wikis but it also have some issues.

Categories and help text

Your wiki should have categories like Category:CS1 maintenance and subcategories for the pages with errors. Each category should have a text to help users know what the error means and how it can be fixed. The relevant help can also be on a help page like Help:CS1 errors.

Do not forget to add interlanguage links so users can jump to English Wikipedia and look for help too.

See also

  • Lua - an page on how Lua works.
  • Lua patterns.
  • <link to relevant help pages>