Pengguna:Ohconfucius/script/EngvarB

Daripada Wikipedia, ensiklopedia bebas.

Templat:Message

Preamble[sunting | sunting sumber]

Within-article consistency of spelling variety

By long-standing convention and as detailed at the Manual of Style, a Wikipedia article needs to consistently use one variety of English. Because editors come from all over the English-speaking world, articles are vulnerable to creeping inconsistency in spelling. These inconsistencies are often difficult to identify quickly, and this script has been developed as an aid to the careful manual oversight of spelling.

The variety is prescribed where an article is related to one of the seven ancestral English-speaking countries; in other cases, the existing variety used in an article—where this is clear—is retained for the sake of stability.

Scope[sunting | sunting sumber]

The EngvarB script is at User:Ohconfucius/script/EngvarB.js.

  • It ensures consistency where BrEng is already predominantly used in an article or should be based on WP:TIES. Its dictionary is limited, and the script may be used on articles about British, Irish, Indian, Pakistani, Australian, New Zealand or South African subjects. It will convert instances of non-British words detected to 'British spelling', on the basis of American and British English spelling differences.
  • It is compatible with Oxford English spelling (OED); that is, users have the option of leaving -iza-, -ize-, and -izi- words untouched; the other option being to change the "s" forms to the "z" forms. (note that 'analyze', 'paralyze' are pure Americanisms, and will be converted to the s-forms regardless of the option chosen)
  • Words within blockquotes, references image names, categories and quote boxes are protected.
  • Because simple or double quotation-marks (' or ") are ambiguous, and it is close to impossible to identify pairing, anything bounded by them is treated as plain text. In other words, instances of American spelling occurring between such quote marks are processed and not ignored: a string such as "anemic rigor" will be changed to "anaemic rigour".

The script adds a non-displaying template {{EngvarB}} or {{EngvarOx}} depending on the conversion used. This tagging allows for easy future maintenance for anybody armed with AWB.

See also[sunting | sunting sumber]

Credits[sunting | sunting sumber]

This javascript tool is my own work, inspired by the work of User:Lightmouse, one of Wikipedia's experts in automated editing. Valuable assistance has been received from Helder.wiki to reorganise and rewrite this code.

Feedback is appreciated at User Talk:Ohconfucius. Please report false negatives as well as false positives. You will find an archive of my talk page exchanges specific to this script on the talk page to this.

Installing the script[sunting | sunting sumber]

  1. Assuming that you are now using vector... Open/create your vector.js page by clicking on this link.
    • If you make a straight copy of this script, instead of "importing" it, you may not benefit from the enhancements and bug-fixes that are made from time to time. In the latter case, you may choose to watchlist this page so you will know when to update your cache for modifications to this script.
  2. Copy the following command onto your vector.js, commons.js or monobook.js page:
    importScript('User:Ohconfucius/script/EngvarB.js');  //<nowiki>[[User:Ohconfucius/script/EngvarB.js]]</nowiki>
    
  3. Save the page and (re-)load it – refresh the cache by following the instructions at the top of your "skin".js page.
  4. Bookmark the script page. This will be your cue to purge the cache on your browser for any updates to take effect.

Disclaimer: Use at your own risk and make sure you check the edit changes before you save.

Actions and test[sunting | sunting sumber]

Use of the Safari browser is highly recommended. The script may take a long time to execute because of the complexities (mainly in the number of lines) of protection mechanism, but I have found it consistently executes much faster in Safari than Firefox, but feel free to give me your feedback on that issue. One instance of failure of execution has been reported.

Once you are in edit mode, there are two buttons in the toolbox in the left margin

  • Flip Convert function – changes unit order in output of {{convert}}, rendering of Imperial units first.
  • BRITISH spelling function – converts occurrences in the body of the text to British English (without z-words).
  • BRITISH (OED) function – converts occurrences in the body of the text to Oxford English spelling (with some z-words)
  • CANADIAN function – converts occurrences in the body of the text to Canadian English spelling (with z-words, and others)

Known limitations[sunting | sunting sumber]

  • Upper-case words, usually denoting proper nouns, are left untouched;
  • instances of words immediately preceded by spaces ( ), square brackets ([), pipe symbols (|) and asterisks (*) will be converted; instances wrapped within single or double quotes (', ") will remain untouched.
  • words that have ambiguous spellings are not changed; 'center' and 'color' are unaltered, as are used in html and formatting parameters. However, words using these as a stem, where unambiguous, are expected to be changed by the script.
  • complex nested structures (for example, infoxes or citation templates with other templates embedded) may cause the script to fail to perform properly.
  • due to uncontrolled template proliferation, false positives may be caused by unanticipated non-protection of certain template parameter names.
  • The script is not a replacement for diligent reading and copyediting to remove words or expressions in perceived American code never used in British vernacular (for example, "to date [somebody]"; "accountabilization" or other similar verbs ending in "ize" that are made into nouns by concatenating "ation").

See also[sunting | sunting sumber]