Jump to content

User:Nardog/IPAInput

From Wikipedia, the free encyclopedia
IPAInput
DescriptionType in IPA symbols by directly looking at an IPA key like Help:IPA/English and clicking on the symbols
UpdatedNovember 2, 2023
    (12 months ago)
BrowsersChrome, Firefox, etc. (ES2018+ needed)
Source

This script adds a button to the editing toolbar that pops up an IPA key (e.g. Help:IPA/English) where you can pick symbols simply by clicking them in the key—so you don't have to go back and forth between the edit form and the key to figure out which symbols to use and repeat copying and pasting—and inserts the string into the edit form, wrapped in {{IPA}} or {{IPAc-en}}.

Installation

[edit]

Add the following to your common.js:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/IPAInput.js&action=raw&ctype=text/javascript');

Or you may enable the script installer in Preferences → Gadgets and click "Install" in the infobox on this page.

Usage

[edit]

You have to have done one of the following in order to use this script:

A "[ə]" icon appears in the editing toolbar (under "Insert" if you're using the 2017 wikitext editor or VisualEditor). It first opens a configuration form.

Configuration

[edit]
Key
Choose a language-specific IPA key under "Help:IPA/...". If you select "(Full IPA chart)", it instead pulls tables from International Phonetic Alphabet chart.
Language
Determines the first argument to pass to {{IPA}} (except for English, in which case {{IPAc-en}} is used).
No template
If this is checked, the transcription will not be wrapped in {{IPA}} or {{IPAc-en}}.
Remember these for next time
If this is checked, the same combination of the key and language will be pre-selected next time you open it. The data is stored in your browser's web storage.

Transcription

[edit]

Hitting "Transcribe" loads the selected key. Any element with the IPA class in the key becomes clickable.

Undo ()
Since the system-native undo becomes unavailable every time a symbol is inserted by clicking inside the key, the script implements its own undo function and overrides Ctrl+Z/+Z. There is no redo (sorry!).
Insert diacritics only ()
Some keys use placeholder letters for illustration of diacritics. This button is useful in such cases. For example, if you click ⟨ǎ⟩ while the button is pressed and the last character before the cursor in the textbox is ⟨e⟩, it becomes ⟨ě⟩ (instead of ⟨⟩). If the key uses the dotted circle⟩ as a placeholder, however, you don't need the button; clicking ⟨◌̌⟩ will turn ⟨e⟩ into ⟨ě⟩ even if the button isn't pressed.

If the English key is used, the input will be divided according to what is accepted by the IPAc-en template (even if it wasn't chosen in the configuration). Also remember the script doesn't take care of the rest of the template (label and audio).