Search code examples
mediawikimediawiki-extensionsmediawiki-templates

MediaWiki get first letter of a string


I want to make a function that will choose "a" or "an" depending on the noun. I am getting that noun from {{PAGENAME}}, which will have Opal, Emerald, Diamond etc.

Is there a parser function or something that I can use to get the first letter? Will also accept extensions or templates that do the same thing.

(I know in English that a word starting with a vowel doesn't always use "an", but for my purposes this doesn't concern me much)

Thanks!


Solution

  • See Template:A or an on English Wikipedia. Note that it relies on other templates and modules that also need to be created on your wiki, which means you'll need the Scribunto extension.