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).

Dictionaries
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.
 * Dictionary/en-GB
 * Dictionary/en-US

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:

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
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
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)

Installation
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
 // Keep the line below. It is used to check the global usage of the script at [[Special:GlobalUsage/User:He7d3r/Tools/LanguageConverter.js]]

// (see [[phab:T35355]])

mw.loader.load( '[//pt.wikibooks.org/w/index.php?title=Utilizador:He7d3r/Tools/LanguageConverterForEnglish.js&action=raw&ctype=text/javascript //pt.wikibooks.org/w/index.php?title=Utilizador:He7d3r/Tools/LanguageConverterForEnglish.js'''&action=raw&ctype=text/javascript]' );

mw.loader.load( '[//pt.wikibooks.org/w/index.php?title=Utilizador:He7d3r/Tools/LanguageConverterForEnglish.css&action=raw&ctype=text/css //pt.wikibooks.org/w/index.php?title=Utilizador:He7d3r/Tools/LanguageConverterForEnglish.css'''&action=raw&ctype=text/css]', 'text/css' );