Module:Lua banner and Template:IPAc1-mh/doc: Difference between pages

From IxWiki
(Difference between pages)
Jump to navigation Jump to search
imported>Fayenatic london
 
imported>Vanisaac
m (→‎top: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
 
Line 1: Line 1:
-- This module implements the {{lua}} template.
{{Documentation subpage}}
local yesno = require('Module:Yesno')
{{IPAc-mh common doc}}
local mList = require('Module:List')
<includeonly>{{Sandbox other||
local mTableTools = require('Module:TableTools')
[[Category:IPA language templates|c-mh]]
local mMessageBox = require('Module:Message box')
}}</includeonly>
 
local p = {}
 
function p.main(frame)
local origArgs = frame:getParent().args
local args = {}
for k, v in pairs(origArgs) do
v = v:match('^%s*(.-)%s*$')
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
 
function p._main(args)
local modules = mTableTools.compressSparseArray(args)
local box = p.renderBox(modules)
local trackingCategories = p.renderTrackingCategories(args, modules)
return box .. trackingCategories
end
 
function p.renderBox(modules)
local boxArgs = {}
if #modules < 1 then
boxArgs.text = '<strong class="error">Error: no modules specified</strong>'
else
local moduleLinks = {}
for i, module in ipairs(modules) do
moduleLinks[i] = string.format('[[:%s]]', module)
local maybeSandbox = mw.title.new(module .. '/sandbox')
if maybeSandbox.exists then
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
end
end
local moduleList = mList.makeList('bulleted', moduleLinks)
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" then
title = title.basePageTitle
end
if title.contentModel == "Scribunto" then
boxArgs.text = 'This module depends on the following other modules:' .. moduleList
else
boxArgs.text = 'This template  uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
end
end
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
return mMessageBox.main('mbox', boxArgs)
end
 
function p.renderTrackingCategories(args, modules, titleObj)
if yesno(args.nocat) then
return ''
end
 
local cats = {}
 
-- Error category
if #modules < 1 then
cats[#cats + 1] = 'Lua templates with errors'
end
 
-- Lua templates category
titleObj = titleObj or mw.title.getCurrentTitle()
local subpageBlacklist = {
doc = true,
sandbox = true,
sandbox2 = true,
testcases = true
}
if not subpageBlacklist[titleObj.subpageText] then
local protCatName
if titleObj.namespace == 10 then
local category = args.category
if not category then
local categories = {
['Module:String'] = 'Templates based on the String Lua module',
['Module:Math'] = 'Templates based on the Math Lua module',
['Module:BaseConvert'] = 'Templates based on the BaseConvert Lua module',
['Module:Citation'] = 'Templates based on the Citation/CS1 Lua module'
}
categories['Module:Citation/CS1'] = categories['Module:Citation']
category = modules[1] and categories[modules[1]]
category = category or 'Lua-based templates'
end
cats[#cats + 1] = category
protCatName = "Templates using under-protected Lua modules"
elseif titleObj.namespace == 828 then
protCatName = "Modules depending on under-protected modules"
end
if not args.noprotcat and protCatName then
local protLevels = {
autoconfirmed = 1,
extendedconfirmed = 2,
templateeditor = 3,
sysop = 4
}
local currentProt
if titleObj.id ~= 0 then
-- id is 0 (page does not exist) if am previewing before creating a template.
currentProt = titleObj.protectionLevels["edit"][1]
end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
if module ~= "WP:libraryUtil" then
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
cats[#cats + 1] = protCatName
break
end
end
end
end
end
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
end
return table.concat(cats)
end
 
return p

Latest revision as of 18:17, 25 April 2020

The template Template:IPAc2-mh, backed by the Scribunto/Lua module Module:IPAc2-mh, is used to produce phonetic representation (using the International Phonetic Alphabet, or IPA) of Marshallese words or sounds. The result is wikilinked to Help:IPA/Marshallese.

Usage

Normal usage:

The template uses, as its first parameter, a special notation describing all the Marshallese phonemes that make up a particular word or phrase. The notation is a modified ASCII-only variation of Bender's orthography. The notation is case-insensitive, but fairly strict in its formatting, and the template will display an error if the notation is malformed. The notation may consist of:

  • ASCII whitespace characters and hyphens (-), which are also ignored.
  • ASCII apostrophes ('), which are mostly ignored.
  • Any of the following ASCII character sequences, representing consonant and vowel phonemes:
    • a b d e & h i 'i j k kw l lh lw m mh n ng ngw nh nw p r rw t w y 'yiy yi'y
  • Multiple separate pronunciation samples may be separated by an ASCII comma (,), but duplicate results will not be displayed.

An ASCII apostrophe may be placed between two sequences disambiguate them, for example l'w to separate l and w so as not to be mistaken for lw.

Consonants

The consonant sequences represent the following phonemes:

Sequence Phoneme Allophones Writing Bender   Sequence Phoneme Allophones Writing Bender   Sequence Phoneme Allophones Writing Bender
p /pʲ/ [pʲ, bʲ] p p b /pˠ/ [pˠ, bˠ] b, bw b  
j /tʲ/ [tʲ, dʲ, t͡sʲ, d͡zʲ, sʲ, zʲ] j j t /tˠ/ [tˠ, dˠ] t t  
  k /k/ [k, ɡ] k k kw /kʷ/ [kʷ, ɡʷ] kw, k kʷ, q
m /mʲ/ [mʲ] m m mh /mˠ/ [mˠ] m̧, m̧w m̧, ṃ, ṁ  
n /nʲ/ [nʲ] n n nh /nˠ/ [nˠ] ņ ņ, ṇ, ṅ nw /nʷ/ [nʷ] ņw, ņ ņʷ, ņ°, ṇʷ, ņ°, n̈
  ng /ŋ/ [ŋ] g ngw /ŋʷ/ [ŋʷ] n̄w, n̄ gʷ, g°, g̈
d /rʲ/ [rʲ] d d r /rˠ/ [rˠ] r r rw /rʷ/ [rʷ] rw, r rʷ, r°, r̈
l /lʲ/ [lʲ] l l lh /lˠ/ [lˠ] ļ ļ, ḷ, ł lw /lʷ/ [lʷ] ļw, ļ ļʷ, ļ°, ḷʷ, ḷ°, l̈
y /j/ [-, ɛ̯, e̯, i̯] -, e, i y h /ɰ/ [-] - h w /w/ [-, w] -, w w

Vowels

There are only four primary vowel sequences:

Sequence Phoneme Allophones Writing Bender
a /æ/ [æ, ɑ, ɒ] ā, a, o̧ a
e /ɛ/ [ɛ, ʌ, ɔ] e, ō, o e
& /e/ [e, ɤ, o] ȩ, ẹ, &
a /i/ [i, ɯ, u] i, ū, u i

In addition, epenthetic vowels are automatically generated between two consonants in an unstable consonant cluster. The vowel automatically chosen depends on the consonants involved and the nearest other neighboring vowels. These epenthetic vowels are marked short: [æ̆ ɛ̆ ĕ ĭ ɑ̆ ʌ̆ ɤ̆ ɯ̆ ɒ̆ ɔ̆ ŏ ŭ]

Special sequences

These sequences take effect at the beginning of a word or after a consonant.

Sequence Phoneme Allophones Writing Bender Notes
yiw /jiw/ [i̯uːw] iuw yiw Use y'iw to avoid this special sequence.
yi'y /ji̯j/ [i̯] i yi'y
'yiy /jijj/ [iː] ii 'yiy

Dialect variation

These sequences produce different results depending on Marshallese dialect, and take effect at the beginning of a word or after a consonant. If a IPA pronunciation varies between the western Rālik Chain dialect and the eastern Ratak Chain dialect, both pronunciations will be displayed.

Sequence Phoneme Rālik Ratak Writing Bender Notes
hha /ɰɰæ/ [ɑː] [ɑ] a, aa hha
wiw /wiw/ [i̯uːw] [uːw] uw, iuw wiw Use w'iw to avoid this special sequence.
yiy /jij/ [iː] [i̯] i, ii yiy Use y'iy to avoid this special sequence.

In addition, if the notation begins with two of the same consonant (other than hh), a prothetic vowel will automatically be added in a different fashion depending on the dialect. For example:

Sequence Phoneme Rālik Ratak Writing Bender
mhmhan /mˠmˠænʲ/ [ɛmˠːɑnʲ] [mˠʌmˠɑnʲ] m̧m̧an, em̧m̧an, m̧ōm̧an m̧m̧an, ṃṃan, ṁṁan

Initial and final vowels

Spoken Marshallese words must always begin or end with a consonant. But because some Marshallese affixes begin or end with a bare vowel that fuses to the consonant of an attached morpheme, the template does not prohibit notations beginning or ending with vowels. In such circumstances, it will display three separate possible pronunciations for each bare vowel, depending on the variable secondary articulations of the consonants which may be attached.

Unlike other vowels the template may display, bare vowels are shown as tied diphthongs, with the implication that the vowel may be pronounced as a diphthong or as one of the two possible surface vowels, in free variation. This is also true of all other vowels in Marshallese, but the most likely pronunciations are simpler for the module to predict when the neighboring consonants and nearest vowels are already known.

To display only one specific reflex instead of all three, any of the special "pseudo-glide" sequences y_ h_ w_ _y _h _w may come at the beginning or end of the notation.

Additional parameters

Additional named parameters may be supplied to alter some of the display aspects of the IPA pronunciation.

diphthongs

If |nobrackets=true is supplied, the IPA pronunciation will display diphthong vowel allophones wherever they may occur:

This mode is not recommended for most pronunciations, as the diphthongs can make the IPA unnecessarily complex to the reader's eyes.

J

This affects only the IPA pronunciation of the phoneme /tʲ/, written ⟨j⟩ in the standard language. Normally, this template displays this phoneme as [tʲ] if it occurs at the beginning or end of a phrase or when geminated, and otherwise displays it as [zʲ]. Since there is a wide variety of allophones for this consonant which may occur in free variation, the parameter J can be used to change which allophones are displayed. The parameter consists of a case-insensitive sequence of four letters, each letter being either t, c or s. For example, cstc. Of the sequence of four letters:

  1. The first letter describes which kind of allophone to use when /tʲ/ occurs at the beginning of a phrase (initial position).
  2. The second letter describes which kind of allophone to use when /tʲ/ occurs either between two vowels or as part of a consonant cluster after /nʲ/.
  3. The third letter describes which kind of allophone to use when /tʲ/ occurs at the end of a phrase (final position).
  4. The fourth letter describes which kind of allophone to use when /tʲ/ is geminated as a double /tʲtʲ/.

Of the three possible different letters:

  • t indicates that particular allophone should be a plosive consonant, either [tʲ] or [dʲ].
  • c indicates that particular allophone should be an affricate consonant, either [t͡sʲ] or [d͡zʲ].
  • s indicates that particular allophone should be a fricative consonant, either [sʲ] or [zʲ].

Example:

Whether the allophones are displayed voiced or voiceless depends on the separate voice parameter.

nobrackets

If |nobrackets=true is supplied, the IPA pronunciation will be displayed without brackets.

  • {{IPAc-mh|yi'yakwey|nobrackets=true}} produces i̯ɒɡwɛ
nohints

If |nohints=true is supplied, there will be no "pseudo-glides" accompanying a word or phrase that begins or ends with a bare vowel.

This is also useful for showing vowel or diphthong allophones in isolation:

voice

Normally, this template displays obstruent consonants with voiceless allophones at the beginning or end of a phrase or when geminated, and voiced allophones in the middle of phrases. If |voice=false or |voice=true are supplied, all obstruent allophones will be displayed either voiceless or voiced.

Limitations

The template will display an error message under certain circumstances:

  • Words may not begin with more than one consonant sequence, unless they are two of the same consonant.
  • Words may not contain sequences of three or more consonants.
  • The special sequences yi'y and 'yiy must always occur directly before a vowel.
  • Pseudo-glides must come either at the beginning or end of a phrase, may not neighbor another consonant, and may not neighbor two vowels.
  • Two vowels may not directly neighbor each other, and must be separated by at least one consonant.

See also