Wikipedia:WikiProject User scripts/Scripts/Language Converter

This script adds a menu at the top of pages and let you change the spellings from/to Britsh/American English based in lists of words (en-US and en-GB), editable by anyone.

You can see the changes directly in the dictionary pages, for example, or accessing articles where there are words in the lists (like Belgium and others).

Features

edit

Dictionaries

edit

The conversion between English variants is done based on the following dictionaries (which are based on this list and still needs to be reviewed by native English speakers):

Both dictionaries are also displayed side by side on this page.

All users can help to improve the dictionaries used by this script editing the corresponding page. All dictionaries use the same syntax to define the conversion rules:

*original expression: converted expression//comments or <ref>Notes about this rule, if necessary</ref>

On this example, "converted expression" is the expression to which "original expression" should be converted (and this is an expression which is present in various articles). The text after "//" will be ignored when converting the page, so it is possible to use this space to add relevant notes about specific rules, to clarify its purpose or help future editors of the dictionary.

If necessary, it is possible to disable a rule (without completely removing it from the dictionary) by changing the "*" by ":". This is useful when a user notice a rule which causes false positives, and the rule can be further discussed on the dictionary talk page and eventually removed. It is also possible to define some regular expressions in the configuration of the script for pre-converting the text.

Avoiding conversion on specific places

edit

It is possible to avoid the conversion of the text of some HTML elements by adding the class "no-conversion" to them. This is useful to avoid false positives in some places.

Local dictionaries

edit

In addition to the global dictionaries, each page can have a local dictionary which will be used through that page. The format is as follows (this can be added to a template similar to this, for easy of use and/or tracking purposes)

<div id="lang-conv" style="display:none;" >
<div id="local-dic-GB">
* some: conversion rule
* another: conversion rule // This is a comment related to this rule
</div><div id="local-dic-US">
* one more: conversion rule
</div></div>

Installation

edit

To install this user script, add the following code to your common.js. It will import the content of the JavaScript and the CSS used by the script.

JavaScript

edit

See also

edit